An Easy Way to Install Python 3 on CentOS 7
The command python in CentOS 7 calls Python 2. To call Python 3, Python 3 must installed. Python 3 can be installed on CentOS 7 by the following easy way.
This method uses Yum. To use Yum, execute the following command for RPM.
sudo yum
install -y https://centos7.iuscommunity.org/ius-release.rpm
Then, execute the following command to check versions of Python 3, which can be installed by Yum.
sudo yum
search python36
Then, execute the following command to install Python 3.
sudo yum
install -y python36u python36u-libs python36u-devel python36u-pip
After this installation, execute the command python3.6, which calls Python3 instead of Python2.
Python 3 starts in the interactive mode. Simple calculation can be easily done as follows:
Python 3 can be used in the script mode as follows.
If tkinter module is needed, it can be installed by Yum as follows
sudo yum
install python36u-tkinter
Executing the command ‘yum search python36u’, we get the following listing (2019.08).
Many modules can be installed by pip3.6 command, which calls the pip command for Python 3. Before using pip3.6, it should be upgraded as follows
sudo pip3.6
install --upgrade pip
This command upgrades pip for Python 3 by pip3.6 command
Then install modules. If you install modules , numpy、matplotlib、scipy, execute the following command.
sudo pip3.6
install numpy matplotlib scipy
If you use the command pip, the modules will be installed for Python 2.
If you want install pystan (the Python interface to Stan), C++ compiler must be installed on CentOS 7.
To check C++ compiler, e.g. execute the command g++.
If the error “no input files” is displayed, that is OK. C++ compiler is installed.
PyStan can be installed by pip3.6 command. At this point 2019.08, I recommend PyStan 2.18.1, which can be installed by the following.
sudo pip3.6
install pystan==2.18.1
Then you can use PyStan on CentOS 7.