1.get-pip.py安裝
(官方)https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
$wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py # 運行安裝腳本
注意:用哪個版本的 Python 運行安裝腳本唠亚,pip 就被關聯(lián)到哪個版本,如果是 Python3 則執(zhí)行以下命令:
$ sudo python3 get-pip.py # 運行安裝腳本双饥。
一般情況 pip 對應的是 Python 2.7蚯姆,pip3 對應的是 Python 3.x
如果顯示
root@66b6f8945ca1:/# python get-pip.py
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-p
y2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 1.8MB/s
Installing collected packages: pip
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Successfully uninstalled pip-18.1
Successfully installed pip-18.1
2.debian系列安裝
apt-get install -y pip (python2.x就去安裝pip2)
apt-get install -y pip-python3 (python3.x就去安裝pip3)
3.RHEL系列
wget --no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz
tar -zvxf 9.0.1.tar.gz -C pip-9.0.1 # 解壓文件
cd pip-9.0.1
python3 setup.py install
pip install --upgrade pip #升級pip(可選)
也就是說1.3方法都是二進制(源代碼)五续,但是我都去裝了,都顯示正確的信息龄恋,如1疙驾。但是無論是pip,還是pip3,還是pip -V,或者pip3 -V郭毕。都沒反應它碎,如同沒裝。不知道為何显押,記錄一下扳肛,以后再試
為什么想要去用二進制裝呢,因為我在制作docker的images乘碑,而apt install挖息,需要先apt update,這樣images會立刻增加200M兽肤。所以為了縮減套腹,就想用二進制裝一些必要的
現(xiàn)在有一個想法,是否需要建立軟連接(ln s )资铡,就如同二進制安裝python時需要建立軟連接沉迹。(20181019)
找到原因了,需要添加到環(huán)境里害驹,第一種我有試了下鞭呕,和之前返回成功信息一樣,但這次信息里多了一些(我把默認改為python3.x)
root@853e19c0f418:/# python -V
Python 3.7.1rc2
root@853e19c0f418:/# python3 -V
Python 3.7.1rc2
root@3547dc8d3d33:/# python get-pip.py
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 1.9MB/s
Collecting wheel
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fc/e9/05316a1eec70c2bfc1c823a259546475bd7636ba6d27ec80575da523bc34/wheel-0.32.1-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
The script wheel is installed in '/usr/python/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-18.1 wheel-0.32.1
root@3547dc8d3d33:/# pip
bash: pip: command not found
root@3547dc8d3d33:/# pip3
bash: pip3: command not found
root@3547dc8d3d33:/# pip list
bash: pip: command not found
顯示成功但還是沒反應,但是多了一條警告葫松,說是
The script wheel is installed in '/usr/python/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
說是沒有添加到path環(huán)境里瓦糕,只是在 '/usr/python/bin',所以你在非其安裝路徑下是不可以執(zhí)行pip相關命令
你如果去其安裝路徑執(zhí)行pip命令腋么,就可以了
root@3547dc8d3d33:/usr/python/bin# ls
2to3 2to3-3.7 easy_install-3.7 idle3 idle3.7 pip pip3 pip3.7 pydoc3 pydoc3.7 python3 python3-config python3.7 python3.7-config python3.7m python3.7m-config pyvenv pyvenv-3.7 wheel
root@3547dc8d3d33:/usr/python/bin# ./pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
.........
.........
所以你只需要把其安裝路徑添加到path環(huán)境里咕娄,就可以全局調用(前兩句(加入,生效))
root@3547dc8d3d33:/# echo 'export PATH=/usr/python/bin:$PATH' >>~/.bashrc
root@3547dc8d3d33:/# source ~/.bashrc
root@3547dc8d3d33:/# cd /
root@853e19c0f418:/# pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
..............
root@853e19c0f418:/# pip3
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
........................
root@853e19c0f418:/# pip -V
pip 18.1 from /usr/python/lib/python3.7/site-packages/pip (python 3.7)
root@853e19c0f418:/# pip3 -V
pip 18.1 from /usr/python/lib/python3.7/site-packages/pip (python 3.7)
pip和pip3都可以
所以第三種安裝方法也應該需要這樣才可以使用珊擂。(20181021)