无法导入setuptools
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法导入setuptools相关的知识,希望对你有一定的参考价值。
我什么都没做,一切都坏了。
aviv$ python3 -c 'import setuptools'
Traceback (most recent call last):
File "/usr/lib/python3.5/pkgutil.py", line 407, in get_importer
importer = sys.path_importer_cache[path_item]
KeyError: ''
这意味着点子被破坏并且气流被破坏。一切都被打破。请帮忙。
编辑:有人建议这是这个问题的重复:Python 3: ImportError "No Module named Setuptools"。我正在做一个不同的事情,并得到一个不同于该问题的错误,我也删除并重新安装了python3-setuptools
与最新版本。仍然得到同样的错误。
编辑2:完全追溯:
Traceback (most recent call last):
File "/usr/lib/python3.5/pkgutil.py", line 407, in get_importer
importer = sys.path_importer_cache[path_item]
KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extern.six.moves import filterfalse, map
File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
@_call_aside
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 626, in _build_master
ws = cls()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 619, in __init__
self.add_entry(entry)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 675, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1929, in find_distributions
importer = get_importer(path_item)
File "/usr/lib/python3.5/pkgutil.py", line 411, in get_importer
importer = path_hook(path_item)
File "<frozen importlib._bootstrap_external>", line 1303, in path_hook_for_FileFinder
File "<frozen importlib._bootstrap_external>", line 95, in _path_isdir
FileNotFoundError: [Errno 2] No such file or directory
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 67, in apport_excepthook
binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))
FileNotFoundError: [Errno 2] No such file or directory
Original exception was:
Traceback (most recent call last):
File "/usr/lib/python3.5/pkgutil.py", line 407, in get_importer
importer = sys.path_importer_cache[path_item]
KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extern.six.moves import filterfalse, map
File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
@_call_aside
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 626, in _build_master
ws = cls()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 619, in __init__
self.add_entry(entry)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 675, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1929, in find_distributions
importer = get_importer(path_item)
File "/usr/lib/python3.5/pkgutil.py", line 411, in get_importer
importer = path_hook(path_item)
File "<frozen importlib._bootstrap_external>", line 1303, in path_hook_for_FileFinder
File "<frozen importlib._bootstrap_external>", line 95, in _path_isdir
FileNotFoundError: [Errno 2] No such file or directory
答案
找到了答案 - 这真的很愚蠢。
我试图从一个不再存在的目录运行所有内容。 os.getcwd()
本身就错了。更改目录,再次运行,现在可以使用。
以上是关于无法导入setuptools的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Windows 上为 python 2.5 导入 argparse 1.2.1
由于 setuptools 无法在 conda 中安装 pytorch 是 conda 的依赖项,无法删除
Setuptools 无法使用来自 dependency_links 的链接
ImportError:在 windows7 32 位中运行 pip --version 命令时无法导入名称 main