python中的一個十分好用的包管理工具python-pip是我們使用python必不可少的一件工具。但是在CentOS7安裝時候卻遇到了一些小問題:
[root@luna magic]# yum install python-pip 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net 沒有可用軟件包 python-pip。 錯誤:無須任何處理
查閱資料以后,原來是因為CentOS官方的源有些時候滯后導致的。所以我們可以用fedora社區打造的EPEL(http://fedoraproject.org/wiki/EPEL)來進行安裝:
[root@luna magic]# sudo yum -y install epel-release 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 epel-release.noarch.0.7-9 將被 安裝 --> 解決依賴關系完成 依賴關系解決 ============================================================================================================= Package 架構 版本 源 大小 ============================================================================================================= 正在安裝: epel-release noarch 7-9 extras 14 k 事務概要 ============================================================================================================= 安裝 1 軟件包 總下載量:14 k 安裝大小:24 k Downloading packages: 警告:/var/cache/yum/x86_64/7/extras/packages/epel-release-7-9.noarch.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY epel-release-7-9.noarch.rpm 的公鑰尚未安裝 epel-release-7-9.noarch.rpm | 14 kB 00:00:00 從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 檢索密鑰 導入 GPG key 0xF4A80EB5: 用戶ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" 指紋 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 軟件包 : centos-release-7-3.1611.el7.centos.x86_64 (@anaconda) 來自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : epel-release-7-9.noarch 1/1 驗證中 : epel-release-7-9.noarch 1/1 已安裝: epel-release.noarch 0:7-9 完畢!
然后再來安裝python-pip:
[root@luna magic]# sudo yum -y install python-pip 已加載插件:fastestmirror, langpacks epel/x86_64/metalink | 5.6 kB 00:00:00 epel | 4.3 kB 00:00:00 (1/3): epel/x86_64/group_gz | 170 kB 00:00:00 (2/3): epel/x86_64/updateinfo | 749 kB 00:00:04 (3/3): epel/x86_64/primary_db | 4.6 MB 00:02:25 Loading mirror speeds from cached hostfile * base: mirrors.btte.net * epel: mirrors.neusoft.edu.cn * extras: mirrors.btte.net * updates: mirrors.btte.net 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 python2-pip.noarch.0.8.1.2-5.el7 將被 安裝 --> 解決依賴關系完成 依賴關系解決 ============================================================================================================= Package 架構 版本 源 大小 ============================================================================================================= 正在安裝: python2-pip noarch 8.1.2-5.el7 epel 1.7 M 事務概要 ============================================================================================================= 安裝 1 軟件包 總下載量:1.7 M 安裝大小:7.2 M Downloading packages: 警告:/var/cache/yum/x86_64/7/epel/packages/python2-pip-8.1.2-5.el7.noarch.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID 352c64e5: NOKEY python2-pip-8.1.2-5.el7.noarch.rpm 的公鑰尚未安裝 python2-pip-8.1.2-5.el7.noarch.rpm | 1.7 MB 00:00:07 從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 檢索密鑰 導入 GPG key 0x352C64E5: 用戶ID : "Fedora EPEL (7) <epel@fedoraproject.org>" 指紋 : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5 軟件包 : epel-release-7-9.noarch (@extras) 來自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : python2-pip-8.1.2-5.el7.noarch 1/1 驗證中 : python2-pip-8.1.2-5.el7.noarch 1/1 已安裝: python2-pip.noarch 0:8.1.2-5.el7 完畢!
然后來運行一下試試看:
[root@luna magic]# pip --help 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. 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. 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.
PS:未經作者授權,謝絕轉載!