Source From Here
Question
I am trying to install a Python app that requires python3 on CentOS system. However, my CentOS only has python 2.X installed, but not python 3.X. How can I install python3 on CentOS?
How-To
As of the latest CentOS 7, the default Python version still remains python 2.7, and python3 is not available in base repositories. If you need to use python3 as part of Python application dependency, there are several ways to install python3 on CentOS.
Method One: Build and Install Python3 from the Source
You can always build python3 from its source manually. Since you can choose the version of python3 to install, this is the surest way to meet Python dependency requirement. Here is how you can build and install python3 from the source.
First, install minimum necessary tools:
Then using yum-builddep, set up a necessary build environment for python3 and install missing dependencies. The following command will automatically take care of that.
Now download the latest python3 (e.g., python 3.5) from https://www.python.org/ftp/python/
Finally, build and install python3 as follows. The default installation directory is /usr/local. If you want to change this to some other directory, pass "--prefix=/alternative/path" parameter to configure before running make.
This will install python3, pip3, setuptools as well as python3 libraries on your CentOS system.
If you want to use python3 as your default Python interpreter, you can define the following alias in your .bashrc.
Method Two: Install Python3 from EPEL Repository
The latest EPEL 7 repository offers python3 (python 3.4 to be exact). Thus if you are using CentOS 7 or later, you can easily install python3 by enabling EPEL repository as follows.
Then install python 3.4 and its libraries using yum:
Note that this will not install matching pip. To install pip and setuptools, you need to install them separately as follows.
Method Three: Install Python3 from Software Collections (SCL)
Another way to install python3 is via enabling Software Collections (SCL) repository. The SCL repository is available for CentOS 6.5 or later, and the latest SCL offers python 3.3. Once you enable the SCL repository, go ahead and install python3 as follows.
To use python3 from the SCL, you need to enable python3 on a per-command basis as follows.
You can also invoke a bash shell with python3 enabled as the default Python interpreter:
Question
I am trying to install a Python app that requires python3 on CentOS system. However, my CentOS only has python 2.X installed, but not python 3.X. How can I install python3 on CentOS?
How-To
As of the latest CentOS 7, the default Python version still remains python 2.7, and python3 is not available in base repositories. If you need to use python3 as part of Python application dependency, there are several ways to install python3 on CentOS.
Method One: Build and Install Python3 from the Source
You can always build python3 from its source manually. Since you can choose the version of python3 to install, this is the surest way to meet Python dependency requirement. Here is how you can build and install python3 from the source.
First, install minimum necessary tools:
Then using yum-builddep, set up a necessary build environment for python3 and install missing dependencies. The following command will automatically take care of that.
Now download the latest python3 (e.g., python 3.5) from https://www.python.org/ftp/python/
Finally, build and install python3 as follows. The default installation directory is /usr/local. If you want to change this to some other directory, pass "--prefix=/alternative/path" parameter to configure before running make.
This will install python3, pip3, setuptools as well as python3 libraries on your CentOS system.
If you want to use python3 as your default Python interpreter, you can define the following alias in your .bashrc.
Method Two: Install Python3 from EPEL Repository
The latest EPEL 7 repository offers python3 (python 3.4 to be exact). Thus if you are using CentOS 7 or later, you can easily install python3 by enabling EPEL repository as follows.
Then install python 3.4 and its libraries using yum:
Note that this will not install matching pip. To install pip and setuptools, you need to install them separately as follows.
Method Three: Install Python3 from Software Collections (SCL)
Another way to install python3 is via enabling Software Collections (SCL) repository. The SCL repository is available for CentOS 6.5 or later, and the latest SCL offers python 3.3. Once you enable the SCL repository, go ahead and install python3 as follows.
To use python3 from the SCL, you need to enable python3 on a per-command basis as follows.
You can also invoke a bash shell with python3 enabled as the default Python interpreter:
沒有留言:
張貼留言