Linux安装python3.7

时间:2024-11-06 17:07:38

1.下载与解压

先到python官网:

https://www.python.org/downloads/release/python-371/](https://www.python.org/downloads/release/python-371/

找到Linux版本安装包的下载路径。

在Linux上先下载安装包,然后进行解包:

[root@localhost ~]#wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
[root@localhost ~]#tar -xzvf Python-3.7..tgz 

2.安装编译工具及库

[root@localhost ~]#cd Python-3.7.
[root@localhost Python-3.7.]# yum install gcc* glien* -y

(安装失败时,可以尝试安装组的开发工具:)

[root@localhost Python-3.7.]# yum grouplist
[root@localhost Python-3.7.]# yum groupinstall '开发工具' -y

3.运行脚本configure

[root@localhost Python-3.7.]# ./configure --prefix=/usr/local/python3.

4.开始编译

[root@localhost Python-3.7.]# make
[root@localhost Python-3.7.]# make install

5.安装成功

Linux安装python3.7)

6.创建快捷路径(3种)

没软链接时每次需要进入python3.7的路径:

[root@localhost bin]# /usr/local/Python3./bin/python3.

1.软链接路径

[root@localhost bin]# ln -s /usr/local/Python3./bin/python3. /bin/python3.

{/bin/python3.}为软链接的路径

2.临时修改环境变量PATH

软件包的存储路径:

[root@localhost ~]# ls /usr/local/Python3./bin/

再将该路径存放在PATH的最后:

[root@localhost ~]# echo $PATH
[root@localhost ~]# PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin:/usr/local/Python3./bin/ 

3.永久修改

运行vim:

[root@localhost ~]# vim /etc/profile

在vim最后添加以下内容后保存:

Linux安装python3.7

创建链接成功:

Linux安装python3.7

7.安装错误

安装make编译时报错ModuleNotFoundError: No module named '_ctypes'的解决办法

[root@localhost ~]# yum install libffi-devel

然后重新安装 

结束。

2018-11-17 17:37:47