Linux安装pip遇到的几个常见问题

问题:安装pip时遇到No module named setuptools

[root@CentOS6 pip-1.5.4]# wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
[root@CentOS6 pip-1.5.4]# tar -xzvf pip-9.0.1.tar.gz
[root@CentOS6 pip-1.5.4]# cd pip-9.0.1
[root@CentOS6 pip-1.5.4]# python setup.py install
Traceback (most recent call last):
File “setup.py”, line 6, in
from setuptools import setup, find_packages
ImportError: No module named setuptools

答案:依赖包setuptools未安装
1.wget setuptools安装包 2.解压缩包 3.cd到setuptools目录下 4.安装setuptools

[root@CentOS6 package]# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
[root@CentOS6 package]# tar -xzvf setuptools-2.0.tar.gz
[root@CentOS6 package]# cd setuptools-2.0
[root@CentOS6 package]# setuptools-2.0

问题:wget遇到ERROR 403: SSL is required.

[root@CentOS6 package]# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
–2019-03-15 18:44:49-- http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
Resolving pypi.python.org… 151.101.0.223, 151.101.64.223, 151.101.128.223, …
Connecting to pypi.python.org|151.101.0.223|:80… connected.
HTTP request sent, awaiting response… 403 SSL is required
2019-03-15 18:44:49 ERROR 403: SSL is required.

答案:将http变为https即可

wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz

问题:安装setuptools时遇到RuntimeError: Compression requires the (missing) zlib module

答案:需要先安装zlib,再进入python源码目录执行重新编译python

[root@CentOS6 package]# yum install zlib
[root@CentOS6 package]# yum install zlib-devel
[root@CentOS6 package]# cd /home/package/python-2.7.3
[root@CentOS6 package]# make clean
[root@CentOS6 package]# make

提示:pip安装完成后,记得软链接,这样才可以在任何目录底下执行pip
ln -s /usr/local/python27/bin/pip /usr/bin/pip

问题:执行pip,遇到ImportError: cannot import name HTTPSHandler

答案:yum安装openssl和openssl-devel。然后重新编译python。

[root@CentOS6 package]# yum install openssl
[root@CentOS6 package]# yum install openssl-devel
[root@CentOS6 package]# cd /home/package/python-2.7.3
[root@CentOS6 package]# make clean
[root@CentOS6 package]# make

你可能感兴趣的:(Linux)