服务器上的Python版本太老了,需要安装一个新的Python版本,才能跑我的代码。因为环境的需要,但是又不能卸载老的版本,所以安装一个新的,使用软链来进行升级。
使用系统自带的yum,apt-get之类的软件那肯定是没办法安装了,需要重源码编译安装。
Linux下如何安装多个Python版本
下载Python源码

http://www.python.org/download/下载源文件。

编译安装
tar zxvf Python-2.7.6.tgz

cd Python-2.7.6

./configure --prefix=/usr/local/python-2.7.6    #重要,指定python的安装路径,可以自己设置。

make

sudo make install
修改Python软链

默认python命令是在/usr/bin/目录下,需要在这里把软链修改成2.7的版本,顺便建立一个2.4的软链。

mv /usr/bin/python /usr/bin/python2.4   #根据需要来

ln -s /usr/local/python-2.7.6/bin/python /usr/bin/python 

本文地址:http://www.linuxprobe.com/linux-install-python.html

相关文章:

  • 2021-07-08
  • 2022-12-23
  • 2021-06-10
  • 2022-01-23
  • 2021-09-07
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2022-02-12
  • 2022-12-23
相关资源
相似解决方案