Update the system software package
yum update -y
Install the software management package and possible dependencies
yum -y groupinstall "Development tools"
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc
Copy the code
Download Pyhton3 to /usr/local
cd /usr/localWget HTTP: / / https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgzCopy the code
Unpack the
The tar ZXVF Python - 3.7.2. TGZ
Go to the python-3.7.2 path
CD Python - 3.7.2
Compile the installation to the specified path
./configure --prefix=/usr/local/python3
Note: the /usr/local/python3 path can be specified by yourself. (If you want a release build with all stable Optimizations active (PGO, etc), Please run./configure –enable-optimizations)
Install python3
make
make install
Copy the code
Note:
Yum install libffi-devel-y refer to this link
After the installation is complete, create a soft link to add variables so that python3 can be used directly in the terminal
ln -s /usr/local/ python3 / bin/python3.7 / usr/bin/python3 ln-s /usr/local/ python3 / bin/pip3.7 / usr/bin/pip3Copy the code
or
You need to modify the original PYTHon2 PATH
mv /usr/bin/python /usr/bin/python2
mv /usr/bin/pip /usr/bin/pip2
Copy the code
Then link the compiled PYTHon3 application to the /usr/bin/ directory
ln -sv /usr/local/python3.7/bin/pip3 /usr/bin/pip
ln -sv /usr/local/ python3.7 / bin/python3 / usr/bin/pythonCopy the code
Note: ln: failed to create symbolic link ‘/usr/bin/python’: File exists
There is a link to /usr/bin/python. Run the command to delete the link
rm -rf /usr/bin/python
/usr/bin/yum/Python2 /usr/bin/yum /usr/bin/yum /usr/bin/yum /usr/bin/yum /usr/bin/yum
Check whether Python3 and PIp3 are installed
python -V
pip -v
Install virtualEnv. It is recommended that you install a VirtualEnv to facilitate project management of different versions
pip install virtualenv
Note: If prompted to upgrade, run the update command PIP install –upgrade PIP
Establish a soft link ln -s/usr/local/python3 / bin/virtualenv/usr/bin/virtualenv
Test virtualenv – version
Two directories are created under the root directory to store env and website files. (Personal habits, other people can handle according to their own actual situation)
mkdir -p /data/env
mkdir -p /data/wwwroot
Copy the code
6. Create a virtual environment of the specified version
Switch to the specified directory
cd /data/env
virtualenv --python=/usr/bin/python pyweb
Copy the code
If the above code succeeds, the virtual environment is successfully installed. Start the virtual environment
cd /data/env/pyweb/bin
source activate
Copy the code
If pyWeb appears, the virtual environment has been successfully entered.
Above, from installation to virtual environment setup, about other installation after tutorial, listed