Python3 Environment Setup

In this chapter, we will show you how to build a Python3 development environment locally.

Python3 can be applied to multiple platforms including Windows, Linux and Mac OS X.

  • Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)

  • Win 9x/NT/2000

  • Macintosh (Intel, PPC, 68K)

  • OS/2

  • DOS (multiple DOS versions)

  • PalmOS

  • Nokia mobile phones

  • Windows CE

  • Acorn/RISC OS

  • BeOS

  • Amiga

  • VMS/OpenVMS

  • QNX

  • VxWorks

  • Psion

  • Python can also be ported to Java and .NET virtual machines.

Python3 Download

The latest Python3 source code, binary files, news, etc. can be viewed on Python's official website:

Python official website:

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

Python document download address:

Python Installation

Python has been ported to many platforms (modified so that it can work on different platforms).

You need to download the binary code for the platform you are using, and then install Python.

If the binary code of your platform is not available, you need to manually compile the source code using a C compiler.

The compiled source code has more functional options and provides more flexibility for Python installation.

The following is the download address of the installation package of each platform:


Source Code can be used for installation on Linux.

The following is how to install Python3 on different platforms.

Install Python3 on Unix & Linux platforms:

The following are simple steps to install Python on Unix & Linux platforms:

  • Open the WEB browser and visit

  • Select the source code compression package suitable for Unix/Linux.

  • Download and unzip the compressed package Python-3.xxtgz , 3.xx is the corresponding version number you downloaded.

  • If you need to customize some options, modify Modules/Setup

Take the Python 3.8.10 version as an example:

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

Check whether Python3 is normally available:

# python3 -V 
Python 3.8.10

Install Python on Window Platform:

The following are simple steps to install Python on the Window platform.

Open the WEB browser to visit , generally download the executable installer, x86 means 32-bit machine, x86-64 means 64-bit machine.


Remember to check Add Python 3.8 to PATH .


Press Win+R , enter cmd to call up the command prompt, enter python:


You can also search for IDLE in the start menu :


Install Python on MAC platform:

MAC systems have their own Python2.7 environment, you can download the latest version and install Python 3.x at the link .

You can also refer to the source installation method to install.

Environment Variable Configuration

Programs and executable files can be in many directories, and these paths are probably not in the search path for executable files provided by the operating system.

The path is stored in an environment variable, which is 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 is case sensitive, Windows is not case sensitive).

In Mac OS, the installation path of Python was changed during the installation process. If you need to reference Python in other directories, you must add the Python directory to the path.

Set Environment Variables on Unix/Linux

  • In the csh shell: type

    setenv PATH "$PATH:/usr/local/bin/python"

    , Press Enter .

  • Enter in the bash shell (Linux):

    export PATH = "$PATH:/usr/local/bin/python" 

    Press Enter .

  • Type in sh or ksh shell:

    PATH = "$PATH:/usr/local/bin/python" 

    Press Enter.

Note: /usr/local/bin/python is the installation directory of Python.

Set Environment Variables in Windows

Add the Python directory in the environment variable:

In the command prompt box (cmd): enter

path =% path %; C : \Python

Press "Enter".

Note: C:\Users\(User)\AppData\Local\Programs\Python\Python(version) is the default installation directory of Python.

It can also be set in the following ways:

  • Right click on "Computer" and then click on "Properties"

  • Then click "Advanced System Settings"

  • Select "Path" under the "System Variables" window and double-click it!

  • image.png

  • Then in the "Path" line, just add the python installation path (In case if you have different versions of Python), so in the back, just add the path.

  • After the final setting is successful, enter the command "python" on the cmd command line to display the relevant display.

Python Environment Variables

The following important environment variables are used in Python:

Variable NameDescription
PYTHONPATHPYTHONPATH is the Python search path. By default, the modules we import will be searched from PYTHONPATH.
PYTHONSTARTUPAfter Python starts, first look for the PYTHONSTARTUP environment variable, and then execute the code in the file specified by this variable.
PYTHONCASEOKAdding the environment variable of PYTHONCASEOK will make python import the module case-insensitive.
PYTHONHOMEAnother module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directory, making it easier to switch between the two module libraries.

Run Python

There are three ways to run Python:

1. Interactive interpreter:

You can enter Python through the command line window and start writing Python codes in the interactive interpreter.

You can do Python coding work on Unix, DOS, or any other system that provides a command line or shell.

$ python              # Unix/Linux
C:>python         # Windows/DOS

The following are the Python command line parameters:

-dDisplay debugging information during parsing
-OGenerate optimized code (.pyo file)
-SDo not introduce the location to find the Python path at startup
-VOutput Python version number
-XSince version 1.6, built-in exceptions (only for strings) are obsolete.
-c cmdExecute the Python script and use the result as a cmd string.
fileExecute a python script in the given python file.

2. Command Line Scripts

You can execute Python scripts on the command line by introducing an interpreter in your application, as shown below:

$ python           # Unix/Linux
C:>python        # Windows/DOS

Note: When executing the python scripts, please check whether the scripts have executable permissions.

3. Integrated Development Environment (IDE: Integrated Development Environment): PyCharm / Visual Studio Code / Any other IDE


PyCharm is a Python IDE created by JetBrains, which supports macOS, Windows, and Linux systems.

PyCharm functions: debugging, syntax highlighting, project management, code jump, smart prompt, auto-completion, unit testing, version control...

PyCharm download link:

Professional (professional version, fee): Complete functions, 30 days trial.

Community (community edition, free): Community edition.

Visual Studio Code

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. 

It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity). 

Visual Studio Code download link: