Linux install python2.7

1. get python2.7 download file

https://www.python.org/downloads/

2. tar xf Python2.7.xx.tar.gz

3. cd Python2.7.xx

# ./configure --prefix=/usr/local
# make && make altinstall (据说这个make altinstall 可以覆盖之前的Python版本,我试了好像没什么卵用 )

如果编译过程中出现C编译依赖错误,可以执行如下命令:

yum groupinstall "Development tools"

4. link the newest version

# unlink /usr/bin/python (一般是系统会安装2.6的版本,并创建了软连接,这里要首先解除原来的软连接)

# link -s /usr/local/bin/python2.7 /usr/bin/python

5. test

# python

6. problem

Python 2.7.10 (default, Oct 29 2015, 04:13:03) 
[GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bae/nanxiu/software/Python-2.7.10/Lib/ssl.py", line 97, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

yum install openssl-devel

然后需要重新编译安装python

参考链接:https://bugs.python.org/issue25526

转载于:https://my.oschina.net/ayy/blog/806406

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值