升级python2至python3解决依赖关系
1.最小化安装centos7,在升级python3的时候会出现很多包未安装,为解决依赖关系:
yum -y install gcc gcc-c++ zlib zlib-devel libffi-devel deltarpm kernel-devel kernel-headers make yum -y install bzip2 bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel yum -y install xz-devel # 为什么要分三步?因为在安装过程中一次性安装的时候,我的服务器出现了这个报错: zvbi-fonts-0.2.35-1.el6.noarch: [Errno 256] No more mirrors to try 分开一步步安装则不报错了
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz tar xf Python-3.6.1.tgz cd Python-3.6.1/ ./configure --prefix=/usr/local/python/python3 make make install mv /usr/bin/python /usr/bin/python.bak ln -s /usr/local/python/python3/bin/python3 /usr/bin/python ln -s /usr/local/python/python3/bin/pip3 /usr/bin/pip vi /usr/bin/yum vi /usr/libexec/urlgrabber-ext-down # 修改/usr/bin/yum和/usr/libexec/urlgrabber-ext-down,将 #!/usr/bin/python 改为 #!/usr/bin/python2.7
2. 这样升级出来的Python3就自动安装了setuptools和pip:
pip的位置是在/usr/local/python/python3/bin/目录下,并不在/usr/local/python/python3/lib/python3.5/site-packages/下,找了十分钟才找到解决办法.
[root@www bin]# pip -V pip 9.0.1 from /usr/local/python/python3/lib/python3.6/site-packages (python 3.6)
python2.7安装pip
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py python ez_setup.py --insecure wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz tar -xf pip-9.0.1.tar.gz cd pip-9.0.1 python setup.py install