我试图通过pip安装numpy。我得到一个错误,它找不到一些文件(不幸的是我没有复制错误)
老实说,我不确定我在那之后做了什么,但pip想更新。然后我得到了另一个错误,当检查Scripts文件夹时,pip已经完全消失了。
从那以后,我尝试了几次重新安装pip通过get-pip.py。总是有相同的错误:
WARNING: Ignoring invalid distribution -ip (c:python39libsite-packages)
WARNING: Ignoring invalid distribution -ip (c:python39libsite-packages)
Collecting pip
Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
WARNING: Ignoring invalid distribution -ip (c:python39libsite-packages)
Installing collected packages: pip
Attempting uninstall: pip
WARNING: Ignoring invalid distribution -ip (c:python39libsite-packages)
Found existing installation: pip 21.3.1
Uninstalling pip-21.3.1:
Successfully uninstalled pip-21.3.1
WARNING: Failed to write executable - trying to use .deleteme logic
Rolling back uninstall of pip
Moving to c:python39libsite-packagespip-21.3.1.dist-info
from C:Python39Libsite-packages~-p-21.3.1.dist-info
Moving to c:python39libsite-packagespip
from C:Python39Libsite-packages~~p
ERROR: Could not install packages due to an OSError: [WinError 2] Can't find the file: 'C:\Python39\Scripts\pip.exe' -> 'C:\Python39\Scripts\pip.exe.deleteme'
WARNING: Ignoring invalid distribution -ip (c:python39libsite-packages)
WARNING: Ignoring invalid distribution -ip (c:python39libsite-packages)
所以它找到一些版本的pip,试图卸载它,但无法安装pip,因为在脚本文件夹中没有pip.exe…?我很抱歉,我无法描述我之前的步骤,我是一个新手,我真的不记得我做过的不同的事情:^)
另外,如果重要的话,python已经在我的PATH中了。我的python版本是3.9.6
存在ensurepip
内置模块
在大多数情况下,Python的最终用户不需要调用这个模块直接(因为
pip
应该在默认情况下引导),但是它可能需要安装pip
时跳过安装Python(或在创建虚拟环境时)或之后显式地卸载pip
.
请尝试如下使用:打开终端并执行
python -m ensurepip