码迷,mamicode.com
首页 > 编程语言 > 详细

centos6安装python3

时间:2015-12-30 23:38:23      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:

到官网找到最新版本源码下载地址
 
 
[root@lxy-zabbix Downloads]# wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
[root@lxy-zabbix Downloads]# tar zxvf Python-3.5.1.tgz 
cd Python-3.5.1
 ./configure --prefix=/usr/local/python3    
make   
make install
 
Installing collected packages: setuptools, pip
Successfully installed pip-7.1.2 setuptools-18.2

 

 
修改旧的python链接
mv /usr/bin/python /usr/bin/python_old

 

 
建立链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

 

运行python
[root@lxy-zabbix Python-3.5.1]# python
Python 3.5.1 (default, Dec 25 2015, 21:48:58) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

 

 
由于centos的yum依赖python2.6,这样一来yum无法使用
[root@lxy-zabbix ~]# yum
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax
 
[root@lxy-zabbix ~]# ll /usr/bin | grep python
-rwxr-xr-x.   1 root root       11016 1月  24 2013 abrt-action-analyze-python
lrwxrwxrwx    1 root root          24 12月 25 21:53 python -> /opt/python3/bin/python3
lrwxrwxrwx.   1 root root           6 11月 14 07:12 python2 -> python
-rwxr-xr-x.   2 root root        9032 10月 13 2012 python2.6
-rwxr-xr-x.   1 root root        1418 10月 13 2012 python2.6-config
lrwxrwxrwx.   1 root root          16 11月 14 07:12 python-config -> python2.6-config
-rwxr-xr-x.   2 root root        9032 10月 13 2012 python_old

 

 
修改yum的配置文件将#!/usr/bin/python改为#!/usr/bin/python2.6
vim /usr/bin/yum
[root@lxy-zabbix ~]# yum
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
You need to give some command
Usage: yum [options] COMMAND
 
List of Commands:

 

 
恢复可用

centos6安装python3

标签:

原文地址:http://www.cnblogs.com/linxingyi/p/5090208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!