我刚刚在新计算机上安装了包请求。我尝试导入该模块时收到此错误。任何想法是什么导致问题与util模块?
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[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 "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/__init__.py", line 58, in <module>
from . import utils
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py", line 36, in <module>
from .connection import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connection.py", line 43, in <module>
from .util import (
ImportError: No module named util
答案 0 :(得分:7)
在pypi.python.org上我看到,最新版本的requests
是2.2.1
您的商家信息显示,您已安装2.3.0版本,因此您可能正在使用尚未完成的开发版本。
卸载它:
$ pip uninstall requests
安装生产质量一:
$ pip install requests
万一,它仍然会破坏版本2.3.0,明确安装2.2.1
$ pip install requests==2.2.1
答案 1 :(得分:0)
如此处所见Bug 1459100 我已经执行了以下命令:
# mv /usr/lib/python2.7/site-packages/requests /usr/lib/python2.7/site-packages/requests_old
然后
dnf install python-requests --best --allowerasing
所以,最后我可以再次启动virt-manager。
我的系统规格: Fedora 25
$ /usr/lib/
python2.7/ python3.5/