Python3 install Linux environment
installation steps
- Download the installation package Python3
Download: https: //download.csdn.net/download/weixin_38422258/12175349
- New installation directory
[root@instance-38r7isl1 /]# cd /usr/local
[root@instance-38r7isl1 local]# mkdir python3
[root@instance-38r7isl1 local]# cd python3
-
Extracting installation package
Unzip files tar.xz: first xz -d xxx.tar.xz will xxx.tar.xz into xxx.tar then decompress, and then tar -xvf xxx.tar to unpack.
-
Compile and install
[root@instance-38r7isl1 Python-3.7.0] yum -y install gcc
[root@instance-38r7isl1 Python-3.7.0]# ./configure --prefix=/usr/local/python3
[root@instance-38r7isl1 Python-3.7.0]# make
[root@instance-38r7isl1 Python-3.7.0]# make install
[root@instance-38r7isl1 Python-3.7.0]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@instance-38r7isl1 Python-3.7.0]# vi /etc/profile
Add the following to configure and save the exit, refresh the configuration (source / etc / profile)
export PATH=$PATH:/usr/local/python3/bin
- Check whether the installation was successful
[root@instance-38r7isl1 Python-3.7.0]# python3 --version
Python 3.7.0
报错解决
(1) zipimport.ZipImportError: can’t decompress data; zlib not available
make: *** [install] Error 1
Solution: Run the following command to re-compile and install
[root@instance-38r7isl1 Python-3.7.0]# sudo yum install zlib*
(2) ModuleNotFoundError: No module named ‘_ctypes’
make: *** [install] Error 1
Solution: Run the following command to re-compile and install from start ./configure
[root@instance-38r7isl1 Python-3.7.0]# yum install libffi-devel