如何在已经存在python2的linux环境上安装python3

如何在已经存在python2的linux环境上安装python3,第1张

如何在已经存在python2的linux环境安装python3

有的人在安装的时候可能会先将python2解除安装掉,这个地方严重强调一下,不要去解除安装系统中已经存在的python2,否则会造成系统中好多其他需要python执行的程式异常

系统环境

[root@localhost install]# pwd

/data/install

[root@localhost install]# cat /etc/redhat-release

CentOS release 6.3 (Final)

[root@localhost install]# uname -a

Linux localhost 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

python3.4的安装方法

[root@localhost install]# wget :python./ftp/python/3.4.4/Python-3.4.4.tgz

[root@localhost install]# tar -zxf Python-3.4.4.tgz

[root@localhost install]# cd Python-3.4.4

# 在安装包中有一个README的档案,里面有写如何安装

[root@localhost Python-3.4.4]# ls

aclocal.m4 config.sub configure.ac Grammar install-sh LICENSE Makefile.pre.in Modules Parser PCbuild Python setup.py

config.guess configure Doc Include Lib Mac Misc Objects PC pyconfig.h.in README Tools

[root@localhost Python-3.4.4]# ./configure

[root@localhost Python-3.4.4]# make

[root@localhost Python-3.4.4]# make install

测试

[root@localhost Python-3.4.4]# python3

Python 3.4.4 (default, Jun 27 2016, 07:47:54)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>>

以后执行python程式就可以使用python3 程式名 去执行了

已经存在python2的linux环境上安装python3,有两种方法,第一种是替换python2,第二种是直接安装python3,而不替换python2,这样的话,在python3执行的时候,就要写成python3+启动等语句

新版宝塔(2019年6月后的)软件商店中有python项目管理器,可以直接安装python各版本。

安装速度很慢,一度以为没成功,又无其他提示,但是面板首页可以看见接收数据在波动。安装大约1-2小时。

python3便安装好了 python -V看看显示的是否3.6版本

修改好后使用yum update -y &&python --version &&pip --version如果yum没有出错而且是python3,且pip版本是python3里面的说明环境搭建成功


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/6204801.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-18
下一篇2023-03-18

发表评论

登录后才能评论

评论列表(0条)

    保存