无法导入设置工具

时间:2019-01-31 19:13:08

标签: python pip setuptools airflow

我什么也没做,一切都坏了。

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

1 个答案:

答案 0 :(得分:2)

找到了答案-这真是愚蠢。

我试图从不再存在的目录中运行所有内容。 os.getcwd()本身出错了。更改目录,再次运行,现在可以使用。