简体   繁体   English

我尝试导入请求时的ImportError消息字符串

[英]String of ImportError messages when I try to import requests

I am trying to run a Python program but encounter a series of errors when I import the requests module (version 2.21.0). 我正在尝试运行Python程序,但在导入请求模块(版本2.21.0)时遇到一系列错误。

I have tried uninstalling requests and re-installing but this does not solve the problem. 我尝试卸载请求并重新安装,但这并没有解决问题。

sudo pip3 uninstall requests
sudo pip3 install requests

Code I am running (in the interactive shell): 代码我正在运行(在交互式shell中):

import re
import requests

I expect the package to simply load, however I am getting the following string of errors: 我希望只是加载包,但是我得到以下错误字符串:

  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/packages/six.py", line 82, in _import_module
    __import__(name)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 71, in <module>
    import email.parser
  File "/Users/willward/Desktop/email.py", line 3, in <module>
    import requests.exceptions
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/exceptions.py", line 9, in <module>
    from urllib3.exceptions import HTTPError as BaseHTTPError
ImportError: cannot import name 'HTTPError' from 'urllib3.exceptions' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/exceptions.py)

I have also tried uninstalling urllib3 and reinstalling it and I get the following errors: 我也尝试卸载urllib3并重新安装它,我收到以下错误:

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import (
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/packages/six.py", line 82, in _import_module
    __import__(name)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 71, in <module>
    import email.parser
  File "/Users/willward/Desktop/email.py", line 3, in <module>
    import requests.exceptions
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/exceptions.py", line 9, in <module>
    from urllib3.exceptions import HTTPError as BaseHTTPError
ImportError: cannot import name 'HTTPError' from 'urllib3.exceptions' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/exceptions.py)

It looks like you are having issue with urllib3. 看起来你遇到了urllib3的问题。 Try to uninstall urllib3 and reinstall it maybe? 尝试卸载urllib3并重新安装它可能吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试从熊猫导入DataFrame时出现ImportError - ImportError when I try to import DataFrame from pandas 当我尝试从pyftpdlib导入ftpserver时,它输出“ ImportError:无法导入名称ftpserver” - When I Try To import ftpserver from pyftpdlib, it outputs “ImportError: cannot import name ftpserver” 尝试“重新导入”模块时,为什么会遇到ImportError? - Why am I encountering an ImportError when I try to 're-import' a module? 熊猫ImportError:当我尝试读取.csv文件时无法导入名称&#39;OrderedDict&#39; - Pandas ImportError: cannot import name 'OrderedDict' when I try to read a .csv file 当我尝试导入TextBlob时,出现“ ImportError:无法导入名称兼容性”。 这是什么意思? 我该如何解决? - When I try to import TextBlob I get “ImportError: cannot import name compat”. What does this mean? How can I fix it? Django:import 仅在 try except 块中导致 ImportError - Django: import causes ImportError only when in try except block 导入错误:无法导入名称请求 - ImportError: cannot import name requests Python - 导入请求 ImportError: No module named requests - Python - import requests ImportError: No module named requests 尝试运行Pyramid时为什么会出现ImportError? - Why am I getting an ImportError when I try to run Pyramid? 当我尝试在 Mac OSX 上使用 pip 时,Python 不工作(ImportError) - Python not working (ImportError) when I try to use pip on Mac OSX
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM