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

What problems should be paid attention to when installing Python3.6 in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article to share with you is about the installation of Python 3.6 in Linux need to pay attention to what problems, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.

Python is a programming language, built-in many effective tools, Python is almost omnipotent, the language is easy to understand, easy to get started, powerful, in many fields have a wide range of applications, such as the most popular big data analysis, artificial intelligence, Web development and so on.

1. Installation dependency environment

Python 3 may use various dependency libraries during installation, so these dependency libraries need to be installed before Python 3 is officially installed.

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 Python 3 source code, one is to download it on its official website, the URL is as follows:

https://www.python.org/downloads/source/

[Photo]

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 the installation directory

The installation directory can be created according to personal preference, for example, created here in/usr/local/python3:

mkdir -p /usr/local/python3

4. Extract source package

Decompress the source package downloaded in step 2. The command is:

tar -zxvf Python-3.6.1.tgz

5. compile source code

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

cd Python-3.6.1./ configure --prefix=/usr/local/python3

Then compile and install:

makemake install

6. Create Python 3 soft links

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:

vim ~/.bash_profile

Add Python 3's startup directory under PATH:

# .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

When you are done, press Esc and type:wq to save and exit.

8. Check if Python 3 and Pip3 are working properly

Execute the following command (note: V is a capital V). If you see the same results, Python 3 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 (python 3.6)

Guide to Pit Avoidance

In fact, for Python 3 installation, there are too many posts on the Internet, and the steps are actually similar. However, after the actual installation, more or less will encounter some trouble, especially for beginners. Here are some common examples:

Pit 1: configure: error: no acceptable C compiler found in $PATH

This problem is relatively simple, is the lack of gcc compilation environment. Install GCC:

yum install -y gcc

Of course, in addition to this, the use of source code installation can also be.

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

This problem is caused by the lack of zlib related toolkits, and the related dependencies can be wrapped:

yum -y install zlib*

After installation and then recompile the source code, you can solve.

Pit 3: Pip3: Can't connect to HTTPS URL because the SSL module is not available

This question is because in... During the configure process, if the-with-ssl parameter is not added, the default software installation related to ssl functionality is unavailable, just as the pip3 process requires ssl modules, and since it is not specified, the functionality is unavailable. 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 redundant version.

First 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 are installed in the system: openssl-1.0.0-27.el6_4.2.x86_64 and openssl-1.0.0-27.el6_4.2.i686. We can leave the x86 version:

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

Update openssl:

# 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 The above is what problems need to be paid attention to when installing Python 3.6 in Linux. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please 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

Servers

Wechat

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

12
Report