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
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:
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:
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:
If there is a dependency problem of the installation package, you can solve it as follows:
(2) Install yum:
So far, yum has been reinstalled successfully!
6、 Install pip
(1) First install the epel extension source:
(2) After the update is complete, you can install pip:
(3) Clear cache after installation:
(4) Upgrade pip:
7、 Install the required libraries
(1) Install NumPy, SciPy, Matplotlib, pandas Statsmodels
(2) Upgrade NumPy, SciPy, Matplotlib, pandas Statsmodels
8、 Install 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 "
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
Recommended Posts