ImportError:无法导入名称' request'

时间:2017-02-21 23:39:10

标签: python request python-import

我是一名Windows用户。我使用命令pip install requests安装了请求,我还键入pip install urllib3以安装urllib3。但是,我无法运行此代码:from requests import request。我收到这样的错误:

Traceback (most recent call last):
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\__init__.py", line 27, in <module>
    from . import urllib3
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\urllib3\connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\urllib3\exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\urllib3\packages\six.py", line 203, in load_module
    mod = mod._resolve()
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\urllib3\packages\six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
  File "D:\Python\lib\http\client.py", line 71, in <module>
    import email.parser
  File "F:\eclipse\workspace\Overseascredit\email.py", line 1, in <module>
    from requests import request
ImportError: cannot import name 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\eclipse\workspace\Overseascredit\email.py", line 1, in <module>
    from requests import request
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\__init__.py", line 60, in <module>
    from .packages.urllib3.exceptions import DependencyWarning
  File "D:\Python\lib\site-packages\requests-2.13.0-py3.5.egg\requests\packages\__init__.py", line 29, in <module>
    import urllib3
  File "D:\Python\lib\site-packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "D:\Python\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "D:\Python\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "D:\Python\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
    mod = mod._resolve()
  File "D:\Python\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "D:\Python\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
  File "D:\Python\lib\http\client.py", line 71, in <module>
    import email.parser
  File "F:\eclipse\workspace\Overseascredit\email.py", line 1, in <module>
    from requests import request
ImportError: cannot import name 'request'

我看到很多答案说有另一个名称重复的文件出现此错误,但是,我搜索了折叠,我找到了一个。我甚至重新安装了我的python,但我仍然遇到了这个错误。请帮帮我。

1 个答案:

答案 0 :(得分:0)

尝试使用     from requests import Request 代替     from requests import request