为什么Windows Powershell上的"pipenv install requests"命令显示错误?



我已经在Windows Powershell上安装了python的最新版本和pipenv。当我尝试安装请求时,它显示以下错误:

FileNotFoundError:[WinError 2]系统找不到指定的文件

ValueError:不是有效的python路径:"C:\ProgramData/Anaconda3/python.exe">

完整错误代码:

Traceback (most recent call last):
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspython.py", line 618, in parse_executable
result_version = get_python_version(path)
File "C:Python39Libsite-packagespipenvvendorpythonfinderutils.py", line 105, in get_python_version
c = subprocess.Popen(version_cmd, **subprocess_kwargs)
File "c:python39libsubprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "c:python39libsubprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:python39librunpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:python39librunpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:Python39Scriptspipenv.exe__main__.py", line 7, in <module>
File "C:Python39Libsite-packagespipenvvendorclickcore.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:Python39Libsite-packagespipenvvendorclickcore.py", line 782, in main
rv = self.invoke(ctx)
File "C:Python39Libsite-packagespipenvvendorclickcore.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:Python39Libsite-packagespipenvvendorclickcore.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:Python39Libsite-packagespipenvvendorclickcore.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:Python39Libsite-packagespipenvvendorclickdecorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:Python39Libsite-packagespipenvvendorclickcore.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:Python39Libsite-packagespipenvvendorclickdecorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:python39libsite-packagespipenvclicommand.py", line 233, in install
retcode = do_install(
File "c:python39libsite-packagespipenvcore.py", line 1920, in do_install
ensure_project(
File "c:python39libsite-packagespipenvcore.py", line 576, in ensure_project
ensure_virtualenv(
File "c:python39libsite-packagespipenvcore.py", line 498, in ensure_virtualenv
python = ensure_python(three=three, python=python)
File "c:python39libsite-packagespipenvcore.py", line 388, in ensure_python
path_to_python = find_a_system_python(python)
File "c:python39libsite-packagespipenvcore.py", line 350, in find_a_system_python
return next(iter(finder.find_all_python_versions()), None)
File "c:python39libsite-packagespipenvvendorpythonfinderpythonfinder.py", line 312, in find_all_python_versions
python_version_dict = getattr(self.system_path, "python_version_dict", {})
File "c:python39libsite-packagespipenvvendorpythonfinderpythonfinder.py", line 120, in system_path
self._system_path = self.create_system_path()
File "c:python39libsite-packagespipenvvendorpythonfinderpythonfinder.py", line 82, in create_system_path
return pyfinder_path.SystemPath.create(
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspath.py", line 682, in create
instance = instance._run_setup()
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspath.py", line 233, in _run_setup
new_instance = new_instance._setup_windows()
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspath.py", line 411, in _setup_windows
windows_finder = WindowsFinder.create()
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelswindows.py", line 146, in create
return cls()
File "<attrs generated init pythonfinder.models.windows.WindowsFinder>", line 13, in __init__
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelswindows.py", line 113, in get_versions
versions[py_version.version_tuple[:5]] = base_dir
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspython.py", line 365, in __getattribute__
result = super(PythonVersion, self).__getattribute__(key)
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspython.py", line 430, in version_tuple
self.patch,
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspython.py", line 375, in __getattribute__
instance_dict = self.parse_executable(executable)
File "C:Python39Libsite-packagespipenvvendorpythonfindermodelspython.py", line 620, in parse_executable
raise ValueError("Not a valid python path: %r" % path)
ValueError: Not a valid python path: 'C:/ProgramData/Anaconda3/python.exe'

您的系统上似乎安装了两个不同的Python发行版:C:Python39中的Python 3.9和C:/ProgramData/Anaconda3/中的Anaconda Python。他们之间有冲突。

我建议您只使用其中一个——Anaconda或官方Python,然后卸载另一个。

最新更新