当我使用pip
安装某些东西时,它失败并出现以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/pkgutil.py", line 412, 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 "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/usr/local/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/local/lib/python3.6/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.models.search_scope import SearchScope
File "/usr/local/lib/python3.6/site-packages/pip/_internal/models/search_scope.py", line 11, in <module>
from pip._internal.utils.misc import normalize_path, redact_password_from_url
File "/usr/local/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 21, in <module>
from pip._vendor import pkg_resources
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3241, in <module>
@_call_aside
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 574, in _build_master
ws = cls()
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 567, in __init__
self.add_entry(entry)
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 623, in add_entry
for dist in find_distributions(entry, True):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1960, in find_distributions
importer = get_importer(path_item)
File "/usr/local/lib/python3.6/pkgutil.py", line 416, in get_importer
importer = path_hook(path_item)
File "<frozen importlib._bootstrap_external>", line 1324, in path_hook_for_FileFinder
File "<frozen importlib._bootstrap_external>", line 102, in _path_isdir
FileNotFoundError: [Errno 2] No such file or directory
我的代码中的pip install
是:
subprocess.Popen('python3 -m pip install -U pip && python3 -m pip install xxx && python3 -m xxx', shell=True)
但是当我直接在外壳中使用pip时,没有任何问题。有人知道出什么问题吗?谢谢!