Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of installing Python3.6 under Linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of Linux installation Python3.6 instance analysis, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this Linux installation Python3.6 instance analysis article. Let's take a look at it.

1. Installation depends on the environment

Python3 may use a variety of dependent libraries during installation, so you need to install these dependent libraries before you formally install python3.

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

two。 Download the python3 source code

There are two ways to download the source code of python3. One is to download it from its official website at the following URL:

[image]

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 your preferences, such as here in / usr/local/python3:

Mkdir-p / usr/local/python3

4. Decompress the source package

Decompress the source code package downloaded in step 2, and the command is:

Tar-zxvf python-3.6.1.tgz

5. Compile source code

First enter the directory of the decompressed source code package, and then configure:

Cd python-3.6.1./configure-prefix=/usr/local/python3

Then compile and then install:

Makemake install

6. Establish a soft link for python3

Ln-s / usr/local/python3/bin/python3 / usr/bin/python3

7. Add / usr/local/python3/bin to path

Edit the bash_profile to modify the environment variables:

Vim / .bash_profile

Add the startup directory of python3 under the path variable:

# .bash _ profile# get the aliases and functionsif [- f ~ / .bashrc]; then. ~ / .bashrcfi # user specific environment and startup programspath=$path:$home/bin:/usr/local/python3/binexport path

After the changes are finished, press esc, and then enter: wq to save and exit.

8. Check whether python3 and pip3 are available

Execute the following command (note: v is uppercase v), and if you see the same results, python3 has been successfully installed.

[alvin@vm_0_16_centos ~] $python3-vpython 3.6.1 [Alvin @ vm_0_16_centos ~] $pip3-vpip 9.0.1 from / usr/local/lib/python3.6/site-packages (python3.6)

Guide to avoiding the pit

In fact, for the installation of python3, there are too many posts on the network, the steps are more or less the same. However, after the actual hands-on installation, there will be more or less trouble, especially for beginners. Here are some common pits:

Pit 1:configure: error: no acceptable c compiler found in $path

The problem is relatively simple, which is the lack of a gcc compilation environment. Just install gcc:

Yum install-y gcc

Of course, in addition to that, it is also possible to install it with source code.

Pit 2:zipimport.zipimporterror: can't decompress data

This problem is caused by the lack of related toolkits for zlib, which can be packaged with related dependencies:

Yum-y install zlib*

It can be solved by recompiling the source code after installation.

Pit 3:pip3: can't connect to https url because the ssl module is not available

This problem is because in the. / configure process, if you do not add the-with-ssl parameter, the default installed software involves the function of ssl is not available, it just happens that the pip3 process requires a ssl module, and because it is not specified, this feature is not available. The solution is as follows:

Cd python-3.6.2./configure-with-sslmakesudo make install

Pit 4:multilib version problems

It is obvious that there are multiple versions of the same library. Just delete the superfluous version.

First of all, query the existing version (take openssl as an example, check which one conflicts)

# rpm-qa | grep opensslopenssl-devel-1.0.0-27.el6_4.2.x86_64openssl-1.0.0-27.el6_4.2.x86_64openssl-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 can leave the x86 version:

Rpm-erase-nodeps openssl-1.0.0-27.el6_4.2.i686

Update openssl again:

# yum update "openssl*"

Check openssl again, problem solved!

# rpm-qa | grep opensslopenssl-devel-1.0.1e-16.el6_5.7.x86_64openssl-1.0.1e-16.el6_5.7.x86_64 's article on "Analysis of Python3.6 instances installed under Linux" ends here. Thank you for reading! I believe you all have a certain understanding of the knowledge of "Python3.6 instance Analysis under Linux installation". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report