gpt4 book ai didi

python-2.7 - Python 和请求 |导入错误 : No module named util

转载 作者:行者123 更新时间:2023-12-01 09:57:17 26 4
gpt4 key购买 nike

我刚刚在新计算机上安装了包请求。当我尝试导入该模块时出现此错误。任何想法是什么导致了 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

最佳答案

我在 pypi.python.org 上看到了 requests 的最新版本是 2.2.1

您的 list 显示,您已经安装了 2.3.0 版本,因此很可能您正在使用尚未真正完成的开发版本。

卸载它:

$ pip uninstall requests

并安装生产质量一:
$ pip install requests

如果它仍然会与 2.3.0 版本混淆,请显式安装 2.2.1
$ pip install requests==2.2.1

关于python-2.7 - Python 和请求 |导入错误 : No module named util,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23378970/

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