0
當我試圖導入在Python 3.4.2的要求,它給了我下面的錯誤:請求給予的錯誤,同時進口的Python 3.4.2
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[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 "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
ImportError: No module named 'email.parser'; 'email' is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/__init__.py", line 60, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
ImportError: No module named 'email.parser'; 'email' is not a package
我並不想使用任何文件,如電子郵件。解析器,但它顯示一個錯誤。我怎樣才能解決這個問題?我試圖再次安裝請求,例如,sudo pip3.4 install requests
和sudo pip3.4 install --upgrade requests
。注意:我正在運行macOS Sierra。
您可能有一個名爲email.py的本地文件,它映射了標準庫模塊。重命名您的文件。 –
非常感謝!如果你給它一個答案,我會接受它@DanielRoseman – vladasha