CentOS 6.3中预安装了Python-2.6.6,其比较新的Python-2.7.15主要区别在于新版本的Python导入了更丰富的模块功能。
安装Python-2.7.15
2.下载Python-2.7.15.tgz, 路径:/usr/local/
3.安装Python
a. 解压
tar -zxvf Python-2.7.15.tgz
b. 安装
cd /usr/local
mkdir python27
cd Python-2.7.15
./configure --prefix=/usr/local/python27 && make && make install
c. 将系统python指令默认指向Python-2.7.15版本
mv /usr/bin/python /usr/bin/python2.6
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
python --version
~~~~~~~~~~~~~~~
[root@node01 pip-9.0.1]# python -V
Python 2.7.15
[root@node01 pip-9.0.1]#
~~~~~~~~~~~~~~~
因为YUM需要python-2.6.6的支持,CentOS 6.3中YUM却不兼容Python-2.7,导致YUM不可用。需要在YUM的配置文件中,重新使YUM指向Python-2.6.6的执行程序(即CentOS 6.3 原始的/usr/bin/python程序)
vim /usr/bin/yum将原来的:#!/usr/bin/python改为:#!/usr/bin/python2.6
wget --no-check-certificate
https://github.com/pypa/pip/archive/9.0.1.tar.gz
1
2
3
|
tar zvxf 9.0.1.tar.gz
cd pip-9.0.1/
python setup.py install
|
缺少
setiptools模块
此时在安装pip的过程执行
python setup.py install时报错,提示:
ImportError No module named setuptools字面意思就是本地缺少setuptools这个模块。
https://pypi.org/project/setuptools/#files
下载setiptools
unzip setuptools-39.2.0.zip
cd setuptools-39.2.0.zip
python setup.py install //安装setuptools
//安装pip
cd pip-9.01
python setup.py install
pip install scipy
~~~~~~~~~~~~~~
Installing collected packages: numpy, scipy
Successfully installed numpy-1.14.3 scipy-1.1.0
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@node01 pip-9.0.1]#
~~~~~~~~~~~~~~~