Article directory
Under windows, the pip that comes with python is uninstalled, how to reinstall pip
When updating pip, the installation was not successful, but the uninstallation was successful! So pip is gone. Solution:
Find the scripts folder of your python installation directory.
win+R to open the DOS command window and enter cmd;
cd to your Scripts folder:
the specific method is as follows:
(1): Directly enter the drive letter:
(2): cd to the Scripts folder in your python installation directory :
(3): Execute the easy_install.exe pip command:
Under Linux, the pip that comes with python is uninstalled, how to reinstall pip
How to install pip in a new Linux system without pip
method 1
1、安装python包管理工具
sudo apt-get install python3.7-distutils # 注意此处python版本要和系统对应
2.1、如果python版本>=3.7,
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
2.2 如果python版本<=3.6
wget https://bootstrap.pypa.io/pip/<python版本>/get-pip.py
# 此处的python版本要和系统对应,支持:2.6、2.7、3.2、3.3、3.4、3.5、3.6
# 例如系统python为python3.6,则下载:wget https://bootstrap.pypa.io/pip/3.6/get-pip.py
python3 get-pip.py
3、验证
pip -V
# 如果pip -V无法显示而pip3 -V可以显示,那就是没有创建pip->pip3的软链接
Method 2
1、下载安装setuptools
wget https://pypi.python.org/packages/28/4f/889339f38da415e49cff15b21ab27becbf4c017c79fbfdeca663f5b33b36/setuptools-36.4.0.zip
unzip setuptools-36.4.0.zip && cd setuptools-36.4.0
python setup.py build && python setup.py install
2、下载安装pip,以下3个版本,任意下载一个即可,以9.0.1为例
#pip22.2.2版本
wget https://files.pythonhosted.org/packages/4b/30/e15b806597e67057e07a5acdc135216ccbf76a5f1681a324533b61066b0b/pip-22.2.2.tar.gz
#pip1.5.4版本
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz
#pip9.0.1版本
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
3、解压安装
tar xf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
4、验证
pip -V
# 如果pip -V无法显示而pip3 -V可以显示,那就是没有创建pip->pip3的软链接
Method 3
sudo apt install python3-pip
Summarize
Method 3 will install pip3 as a system package, and a series of problems such as insufficient permissions, incorrect library version, and inability to import are likely to occur in the later use process, so it is not recommended to use;
Method 2 recommends installing pip9.0.1, because this version is compatible with all python versions;
Method 1 is recommended to use this method. The first step is to install the python development package according to the system environment, and the second step is to install the appropriate pip version according to the system python version and environment;
Linux change pip to domestic mirror source|pip change source|pip modify source
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com
# 该配置文件保存在:
1、系统级: /etc/pip.conf
2、用户级:/home/<username>/.config/pip/pip.conf
# 可以手动修改配置文件,pypi.ngc.nvidia.com为nvidia的库托管地址
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
pypi.ngc.nvidia.com
no-cache-dir = true
extra-index-url = https://pypi.ngc.nvidia.com