从脚本导入已安装的软件包引发“AttributeError:module has no我有一个名为的脚本requests.py导入请求包。该脚本无法访问包中的属性,也无法导入它们。为什么这不起作用,我该如何解决?以下代码提出了一个问题AttributeError。import requests
res = requests.get('http://www.google.ca')print(res)Traceback (most recent call last):
File "/Users/me/dev/rough/requests.py", line 1, in <module>
import requests File "/Users/me/dev/rough/requests.py", line 3, in <module>
requests.get('http://www.google.ca')AttributeError: module 'requests' has no attribute 'get'以下代码提出了一个问题ImportError。from requests import get
res = get('http://www.google.ca')print(res)Traceback (most recent call last):
File "requests.py", line 1, in <module>
from requests import get File "/Users/me/dev/rough/requests.py", line 1, in <module>
from requests import getImportError: cannot import name 'get'或者从requests包内的模块导入的代码:from requests.auth import AuthBaseTraceback (most recent call last):
File "requests.py", line 1, in <module>
from requests.auth import AuthBase
File "/Users/me/dev/rough/requests.py", line 1, in <module>
from requests.auth import AuthBaseImportError: No module named 'requests.auth'; 'requests' is not a package
添加回答
举报
0/150
提交
取消