[英]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.