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

How to install python3 in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to install python3 in Linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to install python3 in Linux.

About python: Python was designed by Guido van Rossum of the Dutch Society for Mathematical and computer Science Research in the early 1990s as an alternative to a language called ABC.

Python provides efficient advanced data structures and simple and effective object-oriented programming.

Python syntax and dynamic typing, as well as the nature of interpreted languages, make it a programming language for scripting and rapid application development on most platforms.

With the continuous update of the version and the addition of new features of the language, it is gradually used for the development of independent, large-scale projects.

The Python interpreter is easy to extend to extend new functions and data types using C or C++ (or any other language that can be called through C).

Python can also be used for extension program languages in customizable software.

Python's rich standard library provides source code or machine code for all major system platforms.

1. Installation depends on environment input command: 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

Download Python3

1. Go to the opt file directory and cd opt/

two。 Download python3 (you can go to the official to see the latest version first)

Enter the command wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

If the wget command cannot be found, type yum-y install wget and its dependencies will be installed

3. Install Python3

Install it in / usr/local/python3 (depending on your personal preference for specific installation location)

(1) create a directory: mkdir-p / usr/local/python3

(2) extract the downloaded Python-3.x.x.tgz package (the specific package name varies depending on the specific version of Python you downloaded, for example: I downloaded Python3.7.1. Then my guy is Python-3.7.1.tgz)

Enter the command tar-zxvf Python-3.7.1.tgz

The folder where python appears after unzipping

4. Enter the extracted directory and compile and install it. (compiler yum install gcc needs to be installed before compilation and installation)

(1) install gcc

Enter the command yum install gcc, confirm to download and install, enter "y"

(2) A new package libffi-devel is required after version 3.7.

Install it: yum install libffi-devel-y

(3) enter the python folder and generate the compilation script (specify the installation directory):

Cd Python-3.7.1

. / configure-prefix=/usr/local/python3

# / usr/local/python3 the directory created for the above step

(4) compile: make

(5) after compiling successfully, compile and install: make install

Installation succeeded:

(6) check the compiler of python3.7: / usr/local/python3/bin/python3.7

5. Build soft chains for Python3 and pip3:

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

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

6. And add / usr/local/python3/bin to PATH

(1) vim / etc/profile

(2) Press "I" and then paste the following:

# vim ~ / .bash_profile

# .bash _ profile

# Get the aliases and functions

If [- f ~ / .bashrc]; then

. ~ / .bashrc

Fi

# User specific environment and startup programs

PATH=HOME/bin:/usr/local/python3/bin

Export PATH

(3) Press ESC, and enter: wq enter to exit.

(4) remember to execute the following command after the modification, and let the previous step change take effect:

Source / .bash_profile

7. Check that Python3 and pip3 are available:

Python3-V

Pip3-V

Thank you for reading, the above is the content of "how to install python3 in Linux". After the study of this article, I believe you have a deeper understanding of how to install python3 in Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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