Linux下升级python

网友投稿 663 2022-10-02

Linux下升级python

Linux下升级python

本文的Linux系统为CentOS 7 64

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

wget -xzvf Python-3.4.4.tgz

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

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

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

但是发现:

checking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking for --enable-universalsdk... nochecking for --with-universal-archs... nochecking MACHDEP... linuxchecking for --without-gcc... nochecking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/home/ttyb/-/Python-3.4.4':configure: error: no acceptable C compiler found in $PATHSee `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 桌面]$ pythonPython 3.4.4 (default, Sep 12 2016, 14:13:28) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linuxType "help", "copyright", "credits" or "license" for more information.

变成了python3.4.4,ok,python升级完成

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:1kkk
下一篇:如何将小程序插入公众号中(如何将小程序添加到公众号)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~