遇到各种问题,记录下来,方便查询
centos6.9自带的Python2.6.6
升级python为2.7.13
源码安装
./configure --prefix=/usr/local/python2.7 --enable-shared
make
make install
原/usr/bin/python为2.6.6 mv /usr/bin/python /usr/bin/python2.6.6并建立软链接
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
运行python报错如下
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
解决方案:
# vi /etc/ld.so.conf 添加新行:/usr/local/python2.7/lib 保存后,运行
# /sbin/ldconfig
# /sbin/ldconfig –v 最后运行python命令
已经切换为2.7.13,python升级成2.7.13后,yum无法使用
解决方案:
cp /usr/bin/yum /usr/bin/yum.bak
首行/usr/bin/python改为#!/usr/bin/python2.6,centos6.9下yum需要在python2.6下运行,改完后yum正常。
安装pip
yum install python-pip
运行pip报错
ImportError: No module named pkg_resources
解决方案:
wget https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip --no-check-certificate
unzip distribute-0.7.3.zip
cd distribute-0.7.3
python setup.py install
引入新报错,估计是切换python2.7后,原来依赖的包都在python2.6的目录下导致,新问题不断ÿ