gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:05:02 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com