linux安装python环境

linux安装python环境,第1张

放到自己准备好的文件夹

2.解压

命令: # tar -zxvf Python-3.8.5.tgz

解压到准备好的文件内

3.进入解压后的目录,编译安装。

cd Python-3.8.5

./configure --prefix=/usr/local/python3

可能会See config.log' for more details出现See config.log' for more details错误,需要安装gcc环境

命令: yum install -y gcc

4.安装:

安装依赖环境:

首先: sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl

然后: make

最后: make install

完成 make install实际上是把生成的执行文件拷贝到之前configure命令指定的目录/usr/local/python3下。

到这里安装已经结束

5.创建软链接

ln -s /usr/tools/Python3/bin/python3 /渣裤穗usr/tools/python3

6.加入环境变量:

vim /etc/profile

增加: export PATH=$PATH:/usr/tools/Python/bin

:wq 退出

source /etc/profile

总结:完成上面的步骤,就完成了python在linux环境的配置。基础知识只能满足你纯旦60%的学习需求,剩下的40%就要在实战中补足,我要做的就是补充你剩下的40%。OK,这次分享就到这里了,有什么疑问可以随时留言沟通,互相学习进步!

欢迎加入QQ群:547349021

小提示:群名虽如卜然叫selenium+unittest,但是我们不限任何测试领域的沟通交流和学习,让我们一起补足缺失的40%吧!

如何在已经存在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+启动等巧禅语句

Linux系统默认是安装有python,可以先在终端输入: python 然后看看是否有回显,如果有就不需要安装了。如果没有,可以按照下面得方法安装:

打开终端,输入:wget

下载完毕后 输入解压铅蔽橡命令:tar –zxvf Python-3.5.0b4.tgz

切换到解压的目录:cd Python*

接下来就是安装:

./configure

make

make install

然后查看一下就槐旁知道了:

输入python如果出现下面的提示:

Python 3.5.0 (#1, Aug 06 2015, 14:04:52)

[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

就说明成功了,因为并升linux系统可能不一样,第二行有可能不同哈。


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

原文地址: https://outofmemory.cn/tougao/12503762.html

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

发表评论

登录后才能评论

评论列表(0条)

保存