在OS X和Linux上都发生了这种情况。不幸的是,我没有完全的重复步骤,但这没关系,因为我将在下面回答我自己的问题。
这是典型的失败:
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] 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 "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/compat.py", line 42, in <module>
from .packages.urllib3.packages.ordered_dict import OrderedDict
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/__init__.py", line 83, in load_module
raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'requests.packages.urllib3'
>>>
答案 0 :(得分:1)
我甚至无法解释为什么,但问题是由于我的文件名为&#34; email.py&#34;在我当前的目录中。我将其重命名为其他内容,突然一切都重新开始了。
坚持&#34;断点&#34; (即故意划分为零的错误)到该文件中,我们可以看到谁正在导入它:
(venv):) 14:36:46 [erichanchrow@Eric-Hanchrows-iMac rack_assigner] (refunds *)$ python -c 'import refund'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "refund.py", line 11, in <module>
import requests
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/__init__.py", line 63, in load_module
__import__(name)
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py", line 10, in <module>
from .connectionpool import (
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 37, in <module>
from .request import RequestMethods
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/urllib3/request.py", line 6, in <module>
from .filepost import encode_multipart_formdata
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/urllib3/filepost.py", line 8, in <module>
from .fields import RequestField
File "/Users/erichanchrow/git-repositories/rack_assigner/venv/lib/python2.7/site-packages/requests/packages/urllib3/fields.py", line 1, in <module>
import email.utils
File "email.py", line 11, in <module>
5/0
ZeroDivisionError: integer division or modulo by zero