gpt4 book ai didi

python - 无法导入名称 ContextualZipFile

转载 作者:太空宇宙 更新时间:2023-11-04 04:51:58 27 4
gpt4 key购买 nike

这是我尝试安装 sqalchemy 时得到的结果

Traceback (most recent call last):
File "/usr/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==33.1.1', 'console_scripts', 'easy_install')()
File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 572, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
return ep.load()
File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2408, in load
return self.resolve()
File "/home/j/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2414, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 51, in <module>
from setuptools.archive_util import unpack_archive
File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 12, in <module>
from pkg_resources import ContextualZipFile
ImportError: cannot import name ContextualZipFile

我已经尝试安装和卸载 setuptools。

我还尝试在我的 usr/local/lib/python2.7/dist-packages/setuptools/archive_util.py 中将“from pkg_resources import ensure_directory, ContextualZipFile”更改为“from pkg_resources import ensure_directory”。但是我得到了错误

Best match: MySQL-python 1.2.5
Processing MySQL-python-1.2.5.zip
Traceback (most recent call last):
File "/usr/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==33.1.1', 'console_scripts', 'easy_install')()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2325, in main
**kw
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 436, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 699, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 725, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 876, in install_eggs
unpack_archive(dist_filename, tmpdir, self.unpack_progress)
File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 53, in unpack_archive
driver(filename, extract_dir, progress_filter)
File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 102, in unpack_zipfile
with ContextualZipFile(filename) as z:
NameError: global name 'ContextualZipFile' is not defined

我也尝试过直接导入 pkg_resources,但仍然找不到 ContextualZipFile。我收到错误:

NameError: global name 'ContextualZipFile' is not defined

我用python 版本 = 2.7.13 和点子版本 = 9.0.1

我也在虚拟环境中这样做

最佳答案

这是一个非常讨厌的 hack,但我只是注释掉了导入,easy_install 似乎工作正常。将对应行改为:

from pkg_resources import ensure_directory#, ContextualZipFile

注意:这是一个系统文件,因此您必须使用 sudo 权限才能更改它。您可以使用:sudo vim 文件名

这不是一个很好的修复,但如果您需要快速让它工作,这应该可以解决问题。希望这对您有所帮助!

关于python - 无法导入名称 ContextualZipFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48051219/

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