centos Installation Python3 and Corresponding pip Tutorial Explanation

  • 2021-07-03 00:29:18
  • OfStack

Installing Python3

Installing Python dependencies:

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

Since Python does not support us to install as an executable program in linux, we need to select the corresponding version source code for installation

Source download site:

https://www.python.org/ftp/python/

Take Python 3.6 as an example:


wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
tar -zxvf Python-3.6.2.tgz
cd Python-3.6.2/

Create an Python installation path:

sudo mkdir /usr/local/python3

Specify the installation path:

./configure --prefix=/usr/local/python3

Execute the installation command:

sudo make && sudo make install

Set up a soft connection for Python in the installation directory

sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3

Note: In the directory of Python3 here, it is actually similar to the directory where Windows installed Python.

The bin directory is similar to the Scripts directory of Python under win, which contains many components of Python and the 3-party modules you will install

Setting PIP for Python3

As the source code installation process, pip and setuptools have been installed by default in Python3, so we only need to set the environment variables of Linux, and create software to connect the/usr/bin/


ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

Since python2 is used by our system, the conservative approach here is that everything in Python3 is called xx3

Of course, you can also modify the default system to use the Python2 address import information to make Python3 the default python environment.

Setting PIP for Python2

Under linux, it now comes with Python2 by default

However, some system types may not have pip as a tool, so we need to install it manually

Install the extension source:

yum -y install epel-release

Install with yum

yum install python-pip

Summarize

The above is the site to introduce you centos installation Python3 and the corresponding pip tutorial details, I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time!


Related articles: