Steps to install python3 under centos7
- 2020-06-03 09:05:42
- OfStack
Environment set up
Prepare tools:
centos7:http://mirror.bit.edu.cn/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso virtuslvox:https://www.virtualbox.org/wiki/Downloads subline secureCRT
1. After installing the virtual machine, add the image file and select minimal to minimize the installation
yum update# Update software
yum -y install gcc kernel-devel kenel-headers make bzip2 # Install dependency libraries
reboot # restart
2. Mount the execution script
mount /dev/cdrom /mnt # Mount the OPTICAL drive to mnt directory
cd /mnt # Into the mnt directory
sh ./VBoxLinuxAdditions.run # Execute the script for installation
reboot # restart
Take snapshots so you can recover later
4. Installation of python environment (Install pyenv)
centos configuration
$ yum install readline readline-devel readline-static -y
$ yum install openssl openssl-devel openssl-static -y
$ yum install sqlite-devel -y
$ yum install bzip2-devel bzip2-libs -y
$ yum install patch vim git
Install python3. 3 / pip3
# The installation python3.3
$ sudo mkdir /usr/local/python3 # Create installation directory
$ wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz # Download the source file. Note: wget To obtain https Add: --no-check-certificate
$ tar -xzvf Python-3.6.0.tgz # Unzip the package
$ cd Python-3.6.0 # Go to the unzip directory
# Compile the installation
$ sudo ./configure --prefix=/usr/local/python3 # Specify the directory to create
$ sudo make
$ sudo make install
# configuration 2 Multiple versions coexist
$ sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3 # create python3 The soft link so that can be passed python Command to use Python 2 . python3 To use the Python 3 .
# Change the default to Python 3
$ sudo mv python python.bak
$ sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python # create python3 The soft links
$ sudo vi /usr/bin/yum # because yum use Python 2 , so replace it with Python 3 After may not work properly, so modify yum Configuration file. Will be the first 1 Line specifies the python Version instead python2.7 ( #!/usr/bin/python Instead of #!/usr/bin/python2.7 )
# The source code to install pip
$ wget --no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz# Download the source code
$ tar -zvxf 9.0.1 -C pip-9.0.1 # Unzip the files
$ cd pip-9.0.1
$ python3 setup.py install# use Python 3 The installation
$ sudo ln -s /usr/local/python3/bin/pip /usr/bin/pip3 # Create links
$ pip install --upgrade pip # upgrade pip
Install setuptools
tar -xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
python setup.py install