云服务器centos系统安装python


1、查看python的版本

$ cd /usr/bin/
$ ls python*
$ ls -al python* //查看依赖关系

2、如果版本不合适可以卸载python再重新安装

# rpm -qa|grep python|xargs rpm -e --allmatches --nodeps   # 卸载python
# wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz 下载python2.7
# tar -zxvf Python-2.7.12.tgz  # 解压
# 将解压的文件放到python2文件夹中
# cd python2
# ./configure
如果报:Bash . configure permission denied的错误,则先运行 #chmod +x ./configure
再运行 ./configure
 
  

  

# make 
# sudo make install # 建立python软连接
# ln
-s /usr/local/bin/python /usr/bin/python // ln -s 新安装的python路径 系统python路径
# 如果提示 ln: creating symbolic link `/usr/bin/python': File exists
# mv /usr/bin/python /usr/bin/python_old // 去除原来存在的软连接
# ln -s /usr/local/bin/python /usr/bin/python //再精选软连接
# vim /usr/bin/yum //将第一行改成 #!/usr/bin/python2.7(具体改成什么使用whereis python看看python的路径,实在不知道是那个的时候可以用最笨的办法
一个个试过),改变yum对python的指向路径
# yum list python #查看指向是否成功,如果没有成功会报 No module named yum 的错误
# vim /usr/libexec/urlgrabber-ext-down //将第一行改成 #!/usr/bin/python2.7(改成上述的一样)

3、安装pip

wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
python get-pip.py
可直接查看配置链接   http://www.cnblogs.com/konglingxi/p/9722351.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM