pipenv 安装包失败 [英] pipenv Failing to Install Packages
问题描述
所以这个错误发生在我为更新的 Python 3.8.3 卸载 Python 3.7.4 之后.我尝试使用 pipenv install
这就是它的输出:
PS C:\Users\enoch\Documents\spectral_curve_calculator>管道安装回溯(最近一次调用最后一次):文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py",第 618 行,在 parse_executableresult_version = get_python_version(path)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\utils.py",第 105 行,在 get_python_versionc = subprocess.Popen(version_cmd, **subprocess_kwargs)文件c:\users\enoch\appdata\local\programs\python\python38\lib\subprocess.py",第 854 行,在 __init__ 中self._execute_child(参数,可执行文件,preexec_fn,close_fds,文件c:\users\enoch\appdata\local\programs\python\python38\lib\subprocess.py",第 1307 行,在 _execute_childhp, ht, pid, tid = _winapi.CreateProcess(executable, args,FileNotFoundError: [WinError 2] 系统找不到指定的文件在处理上述异常的过程中,又发生了一个异常:回溯(最近一次调用最后一次):文件c:\users\enoch\appdata\local\programs\python\python38\lib\runpy.py",第 194 行,在 _run_module_as_main返回_run_code(代码,main_globals,无,文件c:\users\enoch\appdata\local\programs\python\python38\lib\runpy.py",第 87 行,在 _run_code 中exec(代码,run_globals)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Scripts\pipenv.exe\__main__.py",第 7 行,在 <module> 中.文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py",第 829 行,在 __call__返回 self.main(*args, **kwargs)文件 "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in mainrv = self.invoke(ctx)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py",第 1259 行,在调用中返回_process_result(sub_ctx.command.invoke(sub_ctx))文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py",第 1066 行,在调用中返回 ctx.invoke(self.callback, **ctx.params)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py",第 610 行,在调用中返回回调(*args,**kwargs)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py",第 73 行,在 new_func返回 ctx.invoke(f, obj, *args, **kwargs)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py",第 610 行,在调用中返回回调(*args,**kwargs)文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py",第 21 行,在 new_func返回 f(get_current_context(), *args, **kwargs)安装文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\cli\command.py",第232行retcode = do_install(文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py",第 1921 行,在 do_install 中确保项目(文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py",第576行,在ensure_project确保虚拟环境(文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py",第 498 行,在 ensure_virtualenv蟒蛇=确保_蟒蛇(三=三,蟒蛇=蟒蛇)文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py",第388行,在ensure_python中path_to_python = find_a_system_python(python)文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py",第 350 行,在 find_a_system_python 中返回下一个(iter(finder.find_all_python_versions()),无)文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py",第 312 行,在 find_all_python_versionspython_version_dict = getattr(self.system_path, "python_version_dict", {})文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py",第 120 行,在 system_path 中self._system_path = self.create_system_path()文件c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py",第 82 行,在 create_system_path返回 pyfinder_path.SystemPath.create(文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py",第 682 行,在创建中实例 = instance._run_setup()文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py",第 233 行,在 _run_setupnew_instance = new_instance._setup_windows()文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py",第 411 行,在 _setup_windowswindows_finder = WindowsFinder.create()文件C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py",第 146 行,在创建返回 cls()文件所以我删除了所有的 python.
注册表.里面的数据是错误的.
这可能不被推荐,很抱歉我无法很好地解释这一点.因为我只是认为这可能是相关的,而没有考虑注册表的重要性...您可以参考 此 帖子以了解如何操作.
绝望的镜头
在那之后,pipenv 仍然无法正常工作.而这个 parse_executable(cls, path)
仍然打印了两条路径.我尝试了很多以确保 python2.x 不在任何可能的路径中.
- 我删除了
{user}\AppData\Local\Programs\Python
文件夹. - 我删除了
{user}\AppData\Local\Roaming\Python37
文件夹.(我不知道它存在......)
但是,python2.x 还是被 python.py
考虑了.
经过一番苦苦挣扎,我想这可能不是路径的问题,而是程序存在的问题.所以我在我的机器上卸载了python2.x版本.令人惊讶的是,这个绝望的镜头终于奏效了.
简而言之,我认为问题是未完全卸载较旧的python版本,其中可能包括注册表.我希望这可以为您提供为什么会发生此错误以及如何彻底解决此错误的提示.
ps:我仍然很好奇python.py
如何找到不在任何环境变量中的python2.x 版本.
So this error happened after I uninstalled Python 3.7.4 for the newer Python 3.8.3. I try to use pipenv install
and this is what it outputs:
PS C:\Users\enoch\Documents\spectral_curve_calculator> pipenv install
Traceback (most recent call last):
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 618, in parse_executable
result_version = get_python_version(path)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\utils.py", line 105, in get_python_version
c = subprocess.Popen(version_cmd, **subprocess_kwargs)
File "c:\users\enoch\appdata\local\programs\python\python38\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "c:\users\enoch\appdata\local\programs\python\python38\lib\subprocess.py", line 1307, 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:\users\enoch\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\enoch\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Scripts\pipenv.exe\__main__.py", line 7, in <module>
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\cli\command.py", line 232, in install
retcode = do_install(
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 1921, in do_install
ensure_project(
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 576, in ensure_project
ensure_virtualenv(
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 498, in ensure_virtualenv
python = ensure_python(three=three, python=python)
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 388, in ensure_python
path_to_python = find_a_system_python(python)
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 350, in find_a_system_python
return next(iter(finder.find_all_python_versions()), None)
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 312, in find_all_python_versions
python_version_dict = getattr(self.system_path, "python_version_dict", {})
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 120, in system_path
self._system_path = self.create_system_path()
File "c:\users\enoch\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 82, in create_system_path
return pyfinder_path.SystemPath.create(
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 682, in create
instance = instance._run_setup()
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 233, in _run_setup
new_instance = new_instance._setup_windows()
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 411, in _setup_windows
windows_finder = WindowsFinder.create()
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 146, in create
return cls()
File "<attrs generated init pythonfinder.models.windows.WindowsFinder>", line 13, in __init__
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 113, in get_versions
versions[py_version.version_tuple[:5]] = base_dir
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 365, in __getattribute__
result = super(PythonVersion, self).__getattribute__(key)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 430, in version_tuple
self.patch,
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 375, in __getattribute__
instance_dict = self.parse_executable(executable)
File "C:\Users\enoch\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 620, in parse_executable
raise ValueError("Not a valid python path: %r" % path)
ValueError: Not a valid python path: 'C:/Users/enoch/Downloads/WPy64-3741/python-3.7.4.amd64/Scripts/python.exe'
So it seems that the issue happens since it is still trying to reference my old python location even though I already uninstalled it: ValueError: Not a valid python path: 'C:/Users/enoch/Downloads/WPy64-3741/python-3.7.4.amd64/Scripts/python.exe'
I checked my environment variables and paths through control panel; they all point to my new Python 3.8.3 installation. Printing sys.path
, it also never mentions the path of my previous installation. Does anyone have any idea of what's going on? Thank you!
解决方案 Met the exact same error.
Ultimately, I solved this problem by simply deleting the duplicate python version using control panel.
But since you have already deleted the older version, then here is what I have been through, hope it would help.
Python.py
Since the traceback is all about a wrong path, I followed the error message and dug into this pythonfinder\models\python.py
file.
In there I found a method called parse_executable(cls, path)
.
I threw a print(path)
in and it seems that the path
variable was printed twice.
- One for the normal python in my PATH.
- Another for the old python path, python2.x, even it is not in my PATH variable
I play around with this file for a while, trying to figure out how the path
is created and why it includes the zombie python2.x version that's not even a valid python path.
Though barely understand the logic, I thought what happened would be like:
parse_executable() > python 3.8 >
check another version > parse_executable() > python 2.x > traceback
Registries
In order to solve the problem, I started to browse the internet. And this blog pointed out how the registry could come into play.
I followed this answer and found the registries related to python in my machine are completely wrong. My python version should be 3.8, but it is 2.x
So I deleted all the python.
registries. The data in them is wrong.
This may not be recommended and I am sorry I can't explain this well. Because I just thought this could be related without considering how important the registries are... You can refer to this post to find out how to do.
Desperate shots
After that, pipenv was still not working. And this parse_executable(cls, path)
still printed two paths. I tried a lot to make sure that the python2.x was not in any possible paths.
- I deleted
{user}\AppData\Local\Programs\Python
folder.
- I deleted
{user}\AppData\Local\Roaming\Python37
folder.(I didn't know it exists...)
But still, python2.x was considered by python.py
.
After all the struggling, I figured maybe this is not the issue about path, but the existing of a program. So I uninstalled the python2.x version in my machine. Surprisingly this desperate shot worked at last.
In short, I think the problem is incompletely uninstall the older python version, which may include the registries. I hope this could provide you a hint of why this error happened and how to solve it completely.
ps: I am still curious about how python.py
could find the version of python2.x which is not in any environment variables.
这篇关于pipenv 安装包失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!