Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Python3 installation


May 10, 2021 Python3


Table of contents


Python's latest source codes, binary documents, news, and more can be found on Python's website:

Python3 installation


You can download Python's documents in the links below, and you can download documents in formats such as HTML, PDF, and PostScript.

Python3 installation




Python installation


  • Python has been ported on many platforms (modified to make it work on different platforms).
  • You need to download the binary code for the platform you use, and then install Python.
  • If the binary code for your platform is not available, you need to manually compile the source code using the C compiler.
  • The compiled source code is more selective in functionality, providing more flexibility for Python installations.


Here's how to install Python on different platforms:

The Unix and Linux platform installs Python:

Here are some simple steps to install Python on the Unix and Linux platforms:

  • Open the WEB browser to access https://www.python.org/downloads/source/
  • Select the source compression package for Unix/Linux.
  • Download and unzip the Python-3.x.x.tgz 3.x.x your download of the corresponding version number.
  • If you need to customize some options to modify Modules/Setup

Take Python 3.8.5:

Python3 installation

# tar -zxvf Python-3.8.5.tgz
# cd Python-3.8.5
# ./configure
# make && make install

Check that Python3 is working properly:

# python3 -V
Python 3.8.5


Windows Platform Installation Python:

Here are the easy steps to install Python on the Windows platform:

  • Open the WEB browser to access https://www.python.org/downloads/windows/
    Python3 installation
  • Select the Windows Platform Installation Package in the download list in python-3.8.5-amd64.exe -3.8.5 for the version number you want to install, -amd64 system version.
  • After downloading, double-click on the download package and go to the Python installation wizard, the installation is very simple, you just need to use the default settings until the installation is complete.

Windows x86-64 is a 64-bit version

Windows x86 is a 32-bit version


MAC platform installation Python:

MAC systems typically come from environments with Python 2.7 versions, and you can also download the latest https://www.python.org/downloads/mac-osx/ installation on the link to the website.

Python3 installation



Environment variable configuration

  • Programs and executables can be in many directories, and these paths are likely not in the search path where the operating system provides executable files.
  • Path is stored in an environment variable, a named string maintained by the operating system. These variables contain information about the available command-line interpreters and other programs.
  • The path variable in Unix or Windows is PATH (UNIX case sensitive, Windows case insensescies).
  • In Mac OS, the installation path for python was changed during the installer process. If you need to reference Python in another directory, you must add a Python directory to the path.

Set environment variables in Unix/Linux

  • In csh shell: Enter
    setenv PATH "$PATH:/w3cschool/local/bin/python"
    Press Enter.
  • Enter in bash shell (Linux):
    export PATH="$PATH:/w3cschool/local/bin/python" 
    Press Enter.
  • Enter in sh or ksh shell:
    PATH="$PATH:/w3cschool/local/bin/python"
    Press Enter.

Note: /w3cschool/local/bin/python Python's installation directory.

Set environment variables in Windows

Add a Python directory to the environment variable:

In the command prompt box (cmd): Enter

path=%path%;C:\Python 

Press Enter.

Note: C: .Python is Python's installation directory.

You can also set it up by:

  • Right-click "Computer" and then "Property"
  • Then click "Advanced System Settings"
  • Select Path under the System Variables window and double-click!
  • Then on Path line, just add the python installation path (my D: .Python32), so add the path later. p s: Remember, the path uses a half sign ; "Separate!
  • After the last setup is successful, on the cmd command line, enter the python and you can have a relevant display.

Python3 installation


Python environment variable

Here are a few important environment variables that apply to Python:

variable name describe
PYTHONPATH PythonPath is a Python search path. The default we import modules will be found from PythonPath.
PYTHONSTARTUP After Python is started, look for the PythonStartUP environment variable and then perform the code in the file specified by this variable.
PYTHONCASEOK Join the environment variable of PythonCaseok, it will not case sensitive when the Python import module.
PYTHONHOME Another module search path.It usually embedded in the PythonStartup or PythonPath directory, making two modules libraries easier to switch.

Run Python

There are three ways to run Python:

1. Interactive interpreter:

  • You can go to Python through the command-line window and start writing Python code in the interactive interpreter.
  • You can do Python coding at Unix, DOS, or any other system that provides a command line or shell.


$ python # Unix/Linux

Or

C:>python # Windows/DOS

Here are the Python command line parameters:

Option describe
-d Display debugging information when parsing
-O Generate an optimized code ( .pyo File)
-S Do not introduce the location of the Python path when starting
-V Output Python version number
-X The built-in exception (only for strings only) after the 1.6 version is over time.
-c cmd Perform a Python script and run the result as a CMD string.
file Perform a Python script at a given Python file.

2. Command-line script

By introducing an interpreter in your application, you can execute Python scripts on the command line, as follows:

$ python script.py # Unix/Linux

Or

C:>python script.py # Windows/DOS

Note: When executing a script, check that the script has executable permissions.

3. Integrated Development Environment (IDE: Integrated Development Environment): PyCharm