【hacker的错误集】AttributeError:module ‘requests‘ has no attribute ‘get‘

简介: 今天,在给一个粉丝远程解决技术问题的时候,发现的一个大家可能都会犯的错误


4342c163fb3943cba40472af2b1fa49b.jpg


报错内容



今天,在给一个粉丝远程解决技术问题的时候,发现的一个大家可能都会犯的错误

错误内容如下:

2287a6058e1b4c97b1236ec1936e0ffd.png


报错分析



AttributeError:module ‘requests’ has no attribute ‘get’,依旧是使用单词的意思来分析报错原因


AttributeError 属性错误

module 模块

分析可以得出:属性错误:requests没有get属性

居然:好家伙,这咋办啊

hacker:慌什么慌,其实很好解决啦


解决方案



解决方案很简单大家注意他的模块名和文件名都是requests


a0c0b9090bd04b01be334512f57d0684.png


居然:好像是的哦,那应该怎么解决啊


hacker:来,我给你讲讲哈


其实很简单,因为他的模块名和文件名冲突了,当他导入这个库时系统会觉得他导入的是requests.py这个文件,所有会报错,只需要把文件名修改一下就行了

居然:那应该怎么修改啊


hacker:很简单啊,鼠标右键项目,点击Refactor—>Rename修改一下点击Refator就行了

12b61418e39b46d3b0e16e020b63b9b0.png6ab75d24c61945c0952c2a776216bd6a.png


修改完再运行一下看看是否解决了


c12420ecf4484b32b99b4d662b679569.png


完美解决🥳🥳🥳

居然:还得是你啊

hacker:嘻嘻嘻👀👀👀


fc523ae33db145269e860d4a995625d4.jpg

相关文章
|
4月前
|
Python
【Python】已解决:AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
【Python】已解决:AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
215 0
|
3月前
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
131 3
‘;‘ expected,Missing semicolon.Syntax Missing semicolon multi (web,若依定义方法,修改method,之后在mounted()用this
‘;‘ expected,Missing semicolon.Syntax Missing semicolon multi (web,若依定义方法,修改method,之后在mounted()用this
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
AttributeError: module ‘torch.jit‘ has no attribute ‘_script_if_tracing‘
288 0
|
11月前
|
Kubernetes Python 微服务
Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding
Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding
90 0
|
关系型数据库 MySQL Linux
SQLSTATE[HY000]: General error: 1364 Field ‘xxx’ doesn't have a default value 解决办法
SQLSTATE[HY000]: General error: 1364 Field ‘xxx’ doesn't have a default value 解决办法
1578 0
解决办法:ImportError: 'module' object has no attribute 'check_specifier'
解决办法:ImportError: 'module' object has no attribute 'check_specifier'
140 0
AttributeError: partially initialized module ‘jieba‘ has no attribute ‘cut‘ (most likely due to a ci
AttributeError: partially initialized module ‘jieba‘ has no attribute ‘cut‘ (most likely due to a ci
539 0
AttributeError: partially initialized module ‘jieba‘ has no attribute ‘cut‘ (most likely due to a ci
|
Python
AttributeError: module ‘time‘ has no attribute ‘clock‘的解决方法
在python3.10中flask项目运行报错: AttributeError: module 'time' has no attribute 'clock'解决方案 主要原因是因为python3.10中不支持clock了, 需要替换成 time.perf_counter() cpmpat.py文件:
415 0
|
Python
AttributeError module ‘time‘ has no attribute ‘clock‘ 解决方法
在 Pycharm + Python3.8 环境中,调用 time.clock() 报错:AttributeError: module ‘time’ has no attribute ‘clock’
958 0
AttributeError module ‘time‘ has no attribute ‘clock‘ 解决方法