您的位置:首页 > 运维架构 > Linux

Linux下升级python

2016-09-13 19:30 387 查看
本文的Linux系统为CentOS 7 64

在Linux系统的下载文件夹中邮件打开终端,输入命令:

wget http://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz[/code] 
这样子python文件的安装包就会下载到下载这个文件夹里面了:



解压命令:

tar -xzvf Python-3.4.4.tgz


解压完成,切换到该文件夹下,也就是cd

将安装设定在我们前面建立的python3的文件夹下面:

./configure --prefix=/home/ttyb/python3


但是发现:

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/ttyb/下载/Python-3.4.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details


原来是没有gcc,我这里是新安装的Linux,所以我需要安装gcc,安装命令如下:

yum install gcc


但是!

[ttyb@localhost Python-3.4.4]$ yum install gcc已加载插件:fastestmirror, langpacks
您需要 root 权限执行此命令。


我是子账号来玩的,所以要用root账户,切换:

su root


然后要输入密码,就输入密码。成功切换:

[ttyb@localhost Python-3.4.4]$ su root密码:
[root@localhost Python-3.4.4]# yum install gcc


安装了一大堆,中间会让你来几个y/n,全部y就行。

安装完毕后再次运行:

[root@localhost Python-3.4.4]# su ttyb
[ttyb@localhost Python-3.4.4]$ ./configure --prefix=/home/ttyb/python3


这时候就可以安装了,我的是python3.4.4

等他设置好安装位置后,继续安装:

make && make install


安装完毕了过后,将python2.7.5改成python3.4.4,配置环境:

mv /usr/bin/python /usr/bin/python2.7.5


然后随便在桌面打开终端输入:

[root@localhost Python-3.4.4]# python
-bash: /usr/bin/python: 没有那个文件或目录


可以发现python没有了,再配置python3.4.4:

ln -s /home/ttyb/python3/bin/python3 /usr/bin/python


再在桌面检查python的版本:

[ttyb@localhost 桌面]$ python
Python 3.4.4 (default, Sep 12 2016, 14:13:28)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.


变成了python3.4.4,ok,python升级完成
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: