Installation of Python 3 1. Install dependent environment Python3 may use various dependent libraries during the installation process, so before officially installing Python3, you need to install these dependent libraries first. 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 2. Download Python 3 source code There are two ways to download Python3 source code. One is to download it from its official website. The URL is as follows: https://www.python.org/downloads/source/ [picture] Another way is to download directly through wget, such as the following command: wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz 3. Create an installation directory The installation directory can be created according to personal preferences, for example, here it is created in /usr/local/python3: 4. Unzip the source package Decompress the source code package downloaded in step 2. The command is: 5. Compile the source code First enter the directory of the unzipped source package, and then configure it: cd Python-3.6.1 ./configure --prefix=/usr/local/python3 Then compile and install: make make install 6. Create a soft link for Python3 ln -s /usr/local/python3/bin/python3 /usr/bin/python3 7. Add /usr/local/python3/bin to PATH Edit bash_profile to modify environment variables: Add the Python3 startup directory to the PATH variable: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:/usr/local/python3/bin export PATH After the changes are complete, press Esc and enter :wq to save and exit. 8. Check whether Python3 and Pip3 are available Execute the following command (note: V is capitalized). If the results are consistent, Python 3 has been successfully installed. [alvin@VM_0_16_centos ~]$ python3 -V Python 3.6.1 [alvin@VM_0_16_centos ~]$ pip3 -V pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6) Pitfalls In fact, there are too many posts on the Internet about the installation of Python 3, and the steps are actually similar. However, after actually installing it, you will encounter some troubles to a greater or lesser extent, especially for novices. Here are some common pitfalls: Pitfall 1: configure: error: no acceptable C compiler found in $PATH This problem is relatively simple, that is, the lack of gcc compilation environment. Just install gcc: Of course, in addition to this, you can also use the source code installation method. Pitfall 2: zipimport.ZipImportError: can't decompress data This problem is caused by the lack of zlib related toolkits. Just package the related dependencies: yum -y install zlib* After installation, recompile the source code to solve the problem. Pitfall 3: pip3: Can't connect to HTTPS URL because the SSL module is not available This problem is that if the –with-ssl parameter is not added during the ./configure process, the SSL functions of the default installed software are not available. It just so happens that the pip3 process requires the SSL module, but since it is not specified, the function is not available. The solution is as follows: cd Python-3.6.2 ./configure --with-ssl make sudo make install Pitfall 4: Multilib version problems This is obvious, there are multiple versions of the same library. Just delete the extra versions. First query the existing version (take openssl as an example, check the one that conflicts) # rpm -qa | grep openssl openssl-devel-1.0.0-27.el6_4.2.x86_64 openssl-1.0.0-27.el6_4.2.x86_64 openssl-1.0.0-27.el6_4.2.i686 You can see that two versions of openssl, openssl-1.0.0-27.el6_4.2.x86_64 and openssl-1.0.0-27.el6_4.2.i686, are installed in the system. We only need to keep the x86 version: rpm --erase --nodeps openssl-1.0.0-27.el6_4.2.i686 Update openssl again: Check openssl again and the problem is solved! # rpm -qa | grep openssl openssl-devel-1.0.1e-16.el6_5.7.x86_64 openssl-1.0.1e-16.el6_5.7.x86_64 Summarize The above is the guide for installing Python 3.6 under Linux and avoiding pitfalls introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Detailed explanation of Mysql communication protocol
>>: How to simulate enumeration with JS
Table of contents Tutorial Series 1. Introduction...
Table of contents 1. v-text text rendering instru...
In actual work, JavaScript regular expressions ar...
Add in the <Head> tag <meta http-equiv=&q...
Nextcloud is an open source and free private clou...
Preface The electricity in my residence has been ...
Set vim's working mode (temporary) :set (mode...
Overview I believe we often encounter such scenar...
The requirements are as follows Export the table ...
When users install MySQL database for the first t...
Canvas has always been an indispensable tag eleme...
Use the Linux utility certbot to generate https c...
1. Install kvm virtualization : : : : : : : : : :...
Yesterday I wanted to use a:visited to change the...
Table of contents Vue2 Writing Vue3 plugin versio...