Python“导入请求”返回AttributeError

时间:2015-06-04 11:04:47

标签: python macos import module python-requests

我想使用模块'requests',但是,安装后,甚至导入都无法正常工作:

Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "requests.py", line 20, in <module>
    r = requests.post(url, data=json.dumps(payload), headers=headers)
AttributeError: 'module' object has no attribute 'post'

有任何线索吗?

1 个答案:

答案 0 :(得分:1)

好的,我意识到问题是我的实际文件名也是requests.py:D 希望它对某人有所帮助。