下载setuptools
https://pypi.python.org/pypi/setuptools#downloads
tar xzvf setuptools-18.3.2.tar.gz cd setuptools-18.3.2 python setup.py install
下载 pip
https://pypi.python.org/pypi/pip/7.1.2
tar xzvf pip-7.1.2.tar.gz cd pip-7.1.2 python setup.py install
验证
pip -h Usage: pip <command> [options] Commands: install Install packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. search Search PyPI for packages. wheel Build wheels from your requirements. help Show help for commands. General Options: -h, --help Show help. --isolated Run pip in an isolated mode, ignoring environment variables and user configuration. -v, --verbose Give more output. Option is additive, and can be used up to 3 times. -V, --version Show version and exit. -q, --quiet Give less output. --log <path> Path to a verbose appending log. --proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port. --retries <retries> Maximum number of retries each connection should attempt (default 5 times). --timeout <sec> Set the socket timeout (default 15 seconds). --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup. --trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS. --cert <path> Path to alternate CA bundle. --client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format. --cache-dir <dir> Store the cache data in <dir>. --no-cache-dir Disable the cache. --disable-pip-version-check Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
多个 python 版的 pip
# python27 是 python 2.7.10 版本的软件链接 # 使用 python27 将 pip 安装到 python 2.7.10 版本下面 cd setuptools-18.3.2 python27 setup.py install cd pip-7.1.2 python27 setup.py install # 用 pip27 代表 python 2.7.10 版本的 pip ln -s /usr/local/python27/bin/pip2.7 /usr/bin/pip27 # 两个版本的 pip 共存 [root@SZB-L0009074 ~]# which pip /usr/bin/pip [root@SZB-L0009074 ~]# which pip27 /usr/bin/pip27 [root@SZB-L0009074 ~]# ls -l /usr/bin/pip -rwxr-xr-x 1 root root 281 Oct 4 10:32 /usr/bin/pip [root@SZB-L0009074 ~]# ls -l /usr/bin/pip27 lrwxrwxrwx 1 root root 30 Oct 4 22:24 /usr/bin/pip27 -> /usr/local/python27/bin/pip2.7 [root@SZB-L0009074 ~]#
Python 3.5.0 默认安装 pip
因为存在3个版本的python,每个版本都安装了 pip ,为了明确使用,通过软链接加版本号来区分各自版本的 pip 工具。
[root@payun Python-3.5.0]# ls -l /usr/local/python35/bin | grep pip -rwxr-xr-x 1 root root 222 Oct 6 10:18 pip3 -rwxr-xr-x 1 root root 222 Oct 6 10:18 pip3.5 [root@payun Python-3.5.0]# [root@payun Python-3.5.0]# ls -l /usr/local/python35/bin | grep python lrwxrwxrwx 1 root root 9 Oct 6 10:18 python3 -> python3.5 -rwxr-xr-x 2 root root 9582930 Oct 6 10:18 python3.5 lrwxrwxrwx 1 root root 17 Oct 6 10:18 python3.5-config -> python3.5m-config -rwxr-xr-x 2 root root 9582930 Oct 6 10:18 python3.5m -rwxr-xr-x 1 root root 3066 Oct 6 10:18 python3.5m-config lrwxrwxrwx 1 root root 16 Oct 6 10:18 python3-config -> python3.5-config [root@payun Python-3.5.0]# [root@payun Python-3.5.0]# ln -s /usr/local/python35/bin/python3.5 /usr/bin/python35 [root@payun Python-3.5.0]# [root@payun Python-3.5.0]# ln -s /usr/local/python35/bin/pip3.5 /usr/bin/pip35 [root@payun Python-3.5.0]#
pip 安装
# 给 python 3.5.0 安装 paramiko [root@payun Python-3.5.0]# pip35 install paramiko Collecting paramiko Downloading paramiko-1.15.3-py2.py3-none-any.whl (166kB) 100% |████████████████████████████████| 167kB 561kB/s Collecting ecdsa>=0.11 (from paramiko) Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB) 100% |████████████████████████████████| 90kB 417kB/s Collecting pycrypto!=2.4,>=2.1 (from paramiko) Downloading pycrypto-2.6.1.tar.gz (446kB) 100% |████████████████████████████████| 446kB 786kB/s Installing collected packages: ecdsa, pycrypto, paramiko Running setup.py install for pycrypto Successfully installed ecdsa-0.13 paramiko-1.15.3 pycrypto-2.6.1 [root@payun Python-3.5.0]# # 给 python 2.7.10 安装 paramiko [root@payun Python-3.5.0]# pip27 install paramiko Collecting paramiko Using cached paramiko-1.15.3-py2.py3-none-any.whl Collecting ecdsa>=0.11 (from paramiko) Using cached ecdsa-0.13-py2.py3-none-any.whl Collecting pycrypto!=2.4,>=2.1 (from paramiko) Using cached pycrypto-2.6.1.tar.gz Installing collected packages: ecdsa, pycrypto, paramiko Running setup.py install for pycrypto Successfully installed ecdsa-0.13 paramiko-1.15.3 pycrypto-2.6.1 [root@payun Python-3.5.0]# # 验证 paramiko 安装成功 [root@payun Python-3.5.0]# python35 Python 3.5.0 (default, Oct 6 2015, 10:17:03) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import paramiko >>> exit() [root@payun Python-3.5.0]# python27 Python 2.7.10 (default, Oct 4 2015, 23:41:50) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import paramiko >>> exit() [root@payun Python-3.5.0]#