【问题标题】:Python "import requests" return AttributeErrorPython“导入请求”返回 AttributeError
【发布时间】:2015-08-18 23:12:21
【问题描述】:

我想使用模块'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'

有什么线索吗?

【问题讨论】:

  • 有没有可能是您在下载的包目录中,并且您正在尝试导入已卸载的模块?

标签: python macos import module python-requests


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 2017-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-10
    相关资源
    最近更新 更多