Home >Backend Development >Python Tutorial >How to download python and install it

How to download python and install it

ChipsDie
ChipsDieOriginal
2019-05-16 14:42:165192browse

How to download python and install it

This article will introduce you to how to download and install Python locally.

Python can be used on multiple platforms including Linux and windows.

You can enter the "python" command through the terminal window to check whether Python has been installed locally and the installation version of Python.

Python download

Python’s latest source code, binary documents, news information, etc. can be viewed on Python’s official website:

Python official website: https:/ /www.python.org/

You can download Python documentation at the following link. You can download documentation in HTML, PDF, PostScript and other formats.

Python document download address: https://www.python.org/doc/

Installing Python on Unix & Linux platforms (Take Ubuntu as an example)

Step one: Install the dependent environment

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl

Step two: Download the Python3 installation package

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

Or go to the official python website to download it yourself: https://www.python.org /downloads/source/

Step 3: Create the installation directory

My personal habit is to install it in /usr/local/python3 (the specific installation location depends on personal preference)

mkdir -p /usr/local/python3

Step 4: Unzip the installation package

tar -zxvf Python-3.7.2.tgz

Step 5: Enter the decompressed directory, compile and install (you need to install the compiler sudo apt install gcc before compiling and installing)

(1) Enter after decompression Directory

(2) Execute ./configure

./configure --prefix=/usr/local/python3   #/usr/local/python3为安装目录

After executing the configure command, a Makefile will be generated. This Makefile is mainly used by the next make command. used (Linux needs to build (build) program components in the order specified by the Makefile).

(3) Execute the make command

make

make actually compiles the source code and generates an executable file.

(4) Execute the make install command again

make install

make install actually copies the generated execution file to the directory /usr/local/python3 specified by the previous configure command.

The installation has ended here, the following is the configuration environment.

Step 6: Create a soft link for python3

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

Step 7: Add /usr/local/python3/bin to PATH

sudo vim /etc/profile

Then add # at the end of the file ##

export PATH=$PATH:/usr/local/python3/bin

Press ESC, enter: wq and press Enter to exit.

After modification, you need to make this environment variable take effect in the configuration information. Execute the command:

source /etc/profile

to make the profile file take effect immediately.

Step 8: Test whether the installation is successful

$ python3 -V
Python 3.7.2$ pip3 -V
pip 18.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

If the output is as above, it proves that the installation has been successful!

If pip3 -V cannot be found, you can try to create a soft link to pip3:

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

Installing Python on Window platform

The following is for Window Simple steps to install Python on the platform:

Open the WEB browser and visit https://www.python.org/downloads/windows/

Select the Window platform installation package in the download list. The format is: python-XYZ.msi file, XYZ is the version number you want to install.

After downloading, double-click the download package to enter the Python installation wizard. The installation is very simple. You only need to use the default settings and click "Next" until the installation is completed.

Related video recommendation "

Python video tutorial"

The above is the detailed content of How to download python and install it. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to enter pythonNext article:How to enter python