Centos7 install Python2.7

1、 Delete existing Python
[ root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##Forcibly delete installed programs and their associations
[ root@test ~]# whereis python |xargs rm -frv ##Delete all residual files##xargs, allows you to execute some other commands on the output
[ root@test ~]# whereis python ##Verify delete, return no result

2、 Delete existing yum
[ root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
[ root@test ~]# whereis yum |xargs rm -frv

3、 Create directories python and yum to store rpm packages

mkdir /software/python

mkdir /software/yum

4、 Use wget to download the rpm packages of python and yum respectively (note: it must correspond to the version number of the system)
(1) Download the rpm package of python:

cd /software/python to enter the directory

The download path is: http://vault.centos.org/7.1.1503/os/x86_64/Packages//
(Note that the centos version must be correct, my version is 7.1.1503)
The downloaded packages are:
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/python-pycurl-7.19.0-17.el7.x86_64.rpm
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/python-devel-2.7.5-16.el7.x86_64.rpm
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/python-libs-2.7.5-16.el7.x86_64.rpm
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/python-urlgrabber-3.10-6.el7.noarch.rpm
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/rpm-python-4.11.1-25.el7.x86_64.rpm
(2) Download the rpm package of yum:

cd /software/yum

wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/yum-3.4.3-125.el7.centos.noarch.rpm
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.1.1503/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-29.el7.noarch.rpm

5、 Install python and yum rpm package
(1) Install python:

cd /software/python

rpm -ivh python-* rpm-python-*

If there is a dependency problem of the installation package, you can solve it as follows:

rpm -ivh python-* rpm-python-* --nodeps --force

(2) Install yum:

cd /software/yum

rpm -ivh yum-*

So far, yum has been reinstalled successfully!

6、 Install pip
(1) First install the epel extension source:

yum -y install epel-release

(2) After the update is complete, you can install pip:

yum -y install python-pip

(3) Clear cache after installation:

yum clean all

(4) Upgrade pip:

python -m pip install --upgrade pip

7、 Install the required libraries
(1) Install NumPy, SciPy, Matplotlib, pandas Statsmodels

pip install numpy

pip install scipy

pip install matplotlib

pip install pandas

pip install statsmodels

(2) Upgrade NumPy, SciPy, Matplotlib, pandas Statsmodels

pip install --upgrade numpy scipy matplotlib pandas statsmodels

8、 Install scikit-learn

yum install python-tools

pip install --upgrade python-tools

pip install -U scikit-learn

9、 Verify that the installation was successful
$python

import numpy as np
import scipy
import pandas as pd
import sklearn
import matplotlib.pyplot as plt
If an error is reported:

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 115, in
_ backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/init.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in
from six.moves import tkinter as Tk
File "/usr/lib/python2.7/site-packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/usr/lib/python2.7/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/site-packages/six.py", line 82, in _import_module
import(name)
ImportError: No module named Tkinter
Note that tkinter is not installed, use the following command to install:

$ sudo yum install tkinter
After testing, it will be fine

import statsmodels

10、 Install IPython
Install directly via command

pip install ipython

Recommended Posts

Centos6 install Python2.7.13
Centos7 install Python 3.6.
CentOS install Python 3.6
Centos7 install Python2.7
Centos install Python3
CentOS6.8 install python2.7
CentOS + Python3.6+
1.5 Install Centos7
Centos 7.5 python3.6
centos7 install python3 and ipython
CentOS7 install python3 and pip3
CentOS 6.9 compile and install python
Centos6 install python3 pip3 ipython3
CentOS 6 compile and install python 3
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
CentOS7 install MySQL
ubuntu18.04 install python2
Centos7 install protobuf
CentOS 7 install Docker
CentOS7 install GlusterFS
CentOS7 upgrade python3
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
ubuntu12.04 install python3
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Python - centos6 installation
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS quickly install Python3 and pip3
How to install Python 3.8 on CentOS 8
CentOS install PHP
CentOS6 install mist.io
Centos7 install Docker
CentOS7 install mysql
How to install Python on CentOS 8
Install Python3 and ansible under CentOS8
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab