One, centos7 install Python3.6.5 tutorial
1、 Before installing Python, you need to install some dependency problems encountered later (if there are dependency problems, follow the instructions to install):
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install xz gcc zlib zlib-devel wget sqlite-devel openssl-devel -y
2、 Download the Python source code package from the official website
Download link: https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
After the download is complete, upload the source code package to the server
3、 unzip files:
xz -d Python-3.6.5.tar.xz
tar -xvf Python-3.6.5.tar.xz
Note: Unzip the Python file to the /usr/ folder.
4、 Go to the file directory
cd Python-3.6.5
5、 Start to install and compile Python
. /configure --prefix=/usr/Python-3.6.5
Execute the make command (wait for compilation, about five or six minutes)
Execute the make install command (waiting for compilation and installation)
An error occurred during the installation process, the zlib package needs to be installed
yum -y install zlib*
After installing zlib*, recompile
make install
6、 Allow Centos7 system to use Python 3.6 by default
cd /usr/bin/
mv python python.bak #Backup the original file
ln -s /usr/Python-3.6.5/bin/python3.6 /usr/bin/python (pay attention to the case of the first letter of the file)
(Note: ln -s source file, target file as soft link)
7、 Test whether Python 3.6.5 is installed successfully
8、 Because the Python2 used by the yum source is replaced with Python3, it will not work properly. The following information needs to be modified:
Modify yum configuration file:
vi /usr/bin/yum
Change the head of the file #!/usr/bin/python to #!/usr/bin/python2.7
9、 Normal when testing yum:
yum -y install vim
Prompt error, need to modify the following information:
vi /usr/libexec/urlgrabber-ext-down
Change /usr/bin/python to /usr/bin/python2.7
10、 Test again if yum is normal
yum -y install vim
The above steps are the actual operation documents for installing Python 3.6.5 on Centos7.
Two, Centos7 install Ipython 6.1.0
1、 Installation dependent environment
yum install xz gcc zlib zlib-devel wget sqlite-devel openssl-devel -y
2、 Download the ipython installation package
Installation package download address:
wget https://pypi.python.org/packages/79/63/b671fc2bf0051739e87a7478a207bbeb45cfae3c328d38ccdd063d9e0074/ipython-6.1.0.tar.gz#md5=1e15e1ce3f3f722da6935d7ac0e51346
Prompt that wget tool is not installed, use yum to install wget tool
yum -y install wget
Continue to download the ipython installation package
2、 Install ipython
tar xf ipython-6.1.0.tar.gz
cd ipython-6.1.0
Use Python to install ipython (provided that Python is installed)
python setup.py install
3、 Test whether ipython is installed successfully
If such an error occurs, it means that the environment variable is set incorrectly. The modification method is as follows:
alias ipython='python -m IPython'
4、 Prompt the above error, you need to install all missing modules through pip until ipython runs successfully:
Prompt that the'traitlets' module is missing, install the actual module through pip
pip3 install traitlets
5、 Download and install pip
Install the extension source: yum -y install epel-release
Install the Python-pip module: yum install python-pip
ln -sv /usr/Python-3.6.5/bin/pip3 /usr/bin/pip3
6、 Install traitlets module
pip install traitlets
7. pip3 install pygments
8. pip3 install pexpect
9. pip3 install pickleshare
10. pip3 install prompt_toolkit
11. pip3 install simplegeneric
12. Test ipython again:
**Summary: **
I wasted a lot of time in the process of pip installation. I kept prompting -bash: pip3: command not found. I found many methods on the Internet, but it didn't work. Finally, the soft link was created successfully.
Through this installation, we know: During the installation process, you should search more for any problems you encounter, and you will surely find a solution.
Recommended Posts