Linux configure python environment variables

1. Download Python-3.7.0.tgz

Reference website: https://www.python.org/downloads/

Insert picture description here
2. Upload and unzip Python-3.7.0.tgz

The version used here is 3.7.0, decompression needs to keep up with your own file name

tar xf Python-3.7.0

Insert picture description here

3. Install dependent packages

yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel gcc gcc-c++

The installation is successful as shown in the figure below
Insert picture description here

PS: If the installation is unsuccessful, you can consider changing the source (the following command is to install epel source)

yum -y install epel-release

4. Installation

cd
cd Python-3.7.0/
 ./configure --prefix=/usr/local/python
 make && make install

Insert picture description here

cd /usr/local/python/bin/

Copy the following file to/usr/bin
Insert picture description here

cp python3 /usr/bin/

5. Test

Insert picture description here

6. Write a file for testing

vim hello.py
#!/usr/bin/python3
print("hello world")

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_50345511/article/details/112556630