python - python 6 的奇怪问题 : cannot import urllib

标签 python raven six

raven附带其自己的 six 版本module 这似乎阻止我导入独立六个模块中存在的模块。请看下面:

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> from raven.utils import six       
>>> dir(six.moves)
['__doc__', '__name__']
>>> 
>>> 
>>> import six
>>> six.__version__
'1.9.0'
>>> 
>>> 
>>> 
>>> dir(six.moves)
['BaseHTTPServer', 'CGIHTTPServer', 'SimpleHTTPServer', 'StringIO', 'UserDict', 'UserList', 'UserString', '__doc__', '__name__', '_dummy_thread', '_thread', 'builtins', 'cPickle', 'cStringIO', 'configparser', 'copyreg', 'dbm_gnu', 'email_mime_base', 'email_mime_multipart', 'email_mime_nonmultipart', 'email_mime_text', 'filter', 'filterfalse', 'html_entities', 'html_parser', 'http_client', 'http_cookiejar', 'http_cookies', 'input', 'intern', 'map', 'queue', 'range', 'reduce', 'reload_module', 'reprlib', 'shlex_quote', 'socketserver', 'tkinter', 'tkinter_colorchooser', 'tkinter_commondialog', 'tkinter_constants', 'tkinter_dialog', 'tkinter_dnd', 'tkinter_filedialog', 'tkinter_font', 'tkinter_messagebox', 'tkinter_scrolledtext', 'tkinter_simpledialog', 'tkinter_tix', 'tkinter_tkfiledialog', 'tkinter_tksimpledialog', 'tkinter_ttk', 'urllib', 'urllib_error', 'urllib_parse', 'urllib_robotparser', 'winreg', 'xmlrpc_client', 'xmlrpc_server', 'xrange', 'zip', 'zip_longest']
>>> 
>>> 
>>> 
>>> 
>>> import six.moves.urllib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named urllib
>>> 
>>> 
>>> 

要重现此问题,请在虚拟环境中安装 requests==0.14.1 以及 motoraven 并运行以下脚本:

from raven.utils import six as six1
from moto import mock_s3

任何提示将不胜感激。

最佳答案

我收到 Sentry 支持的回复并使用他们的提示,我发现如果您安装 requests-0.14.2 (我已经安装了),这个错误很容易出现。我升级了请求,但这种情况不再发生。

相关链接:Moto issue on GitHub

关于python - python 6 的奇怪问题 : cannot import urllib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34667533/

相关文章:

python - Django 迭代 - 计算总和

javascript - 用户对 Sentry 报告对话框未提交的反馈

python - Sentry - 如何只记录异常,而不是记录器

python-2.7 - Wagtail Docker 六包冲突升级到 wagtail 1.7

Python 导入错误 : cannot import name 'six' from 'sklearn.externals'

python - 为什么 six.py 使用自定义类来查找 MAXSIZE?

python - 如何使用 gunicorn 在 django 中编写 log.info() 以进行控制台?

python - 散点图的轴限制不在 matplotlib 中

python - 如何为所有 ctype 结构类设置 __str__ 方法?

python - 为不同的环境(登台、生产)配置 Sentry