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 is the method of installing python3 under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this article Xiaobian for you to introduce in detail "what is the method of installing python3 under Linux", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "what is the method of installing python3 under Linux" can help you solve your doubts.

1. Install the dependencies that may be used by python3.6 first

# yum-y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel zlib-devel

2. Download the python source code package with the address of https://www.python.org/downloads/source/, and then upload it through xftp, or directly use the wget command to download wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz to the local.

# tar-zxvf Python-3.6.1.tgz# cd Python-3.6.1/

3. Install python3.6 into the / usr/local directory

#. / configure-prefix=/usr/local/# make# make altinstall

4. Change / usr/bin/python link

# cd / usr/bin# mv python python.backup# ln-s / usr/local/bin/python3.6 / usr/bin/python# ln-s / usr/local/bin/python3.6 / usr/bin/python3# rm-rf / usr/bin/python2# ln-s / usr/bin/python2.7 / usr/bin/python2

5. Change the python dependency of yum scripts

# cd / usr/bin# ll yum*

The following documents are available:

-rwxr-xr-x 1 root root 802 Jan 2 17:53 yum-rwxr-xr-x 1 root root 9374 Jan 2 17:53 yum-builddep-rwxr-xr-x 1 root root 8091 Jan 2 17:53 yum-config-manager-rwxr-xr-x 1 root root 7610 Jan 2 17:53 yum-debug-dump-rwxr-xr-x 1 root root 7904 Jan 2 17:54 yum-debug-restore-rwxr-xr-x 1 root root 10906 Jan 2 17:54 yumdownloader-rwxr-xr-x 1 root root 11032 Jan 2 17:54 yum-groups-manager

Modify the above file header: #! / usr/bin/python to #! / usr/bin/python2

You can install a tree to test it.

# yum-y install tree

If the following error occurs: File "/ usr/libexec/urlgrabber-ext-down", line 28

Vim / usr/libexec/urlgrabber-ext-down

Just change / usr/bin/python to / usr/bin/python2.

In this way, yum will not report an error when installing the software, and the default installation is python3. When you enter python, you will enter the python3 interface. If you want to enter python2, enter python2.

After reading this, the article "what is the method of installing python3 under Linux" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, 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

Development

Wechat

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

12
Report