Ubuntu下多个Python版本共存

一个方法是使用virtuallen环境,另一方法是使用pyenv

virtuallen

使用virtuallen管理多个python版本,需要先安装多个python环境

1. ubuntu下源代码安装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软链的目的是使ubuntu的默认的python环境是你所安装的环境,这一步不是必须的。默认python命令是在/usr/bin/目录下,需要在这里把软链修改成2.7的版本,顺便建立一个2.4的软链。

mv /usr/bin/python /usr/bin/python2.4   #原来的软链改名为python2.4 
ln -s /usr/local/python-2.7.6/bin/python /usr/bin/python 
#新建一个python的软链,链接到编译安装的python的bin目录中的python程序
安装使用virtuallen

可能需要安装pip

sudo pip install virtualenv

错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

参考这篇文章:https://blog.csdn.net/jeryjeryjery/article/details/77880227
解决方法就是重新编译:

cd Python-3.6.2
./configure --with-ssl
make
sudo make install

给出了警告:

configure: WARNING: unrecognized options: --with-ssl

换另外一种方法ssl module in Python is not available的解决方法https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3

最后的执行pip install virtualenv出错:

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

参考这篇文章:https://blog.csdn.net/tintinetmilou/article/details/80091630

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值