Python3 Environment Setup and Installation Guide
This article provides a comprehensive guide to installing and configuring Python 3 on various platforms—including Windows, Linux, and macOS—covering download sources, installation steps, environment variable setup, and usage of command‑line options and IDEs.
This section introduces how to set up a local Python 3 development environment.
Python 3 runs on many platforms such as Windows, Linux, and macOS.
Python3 Download
The latest source code, binaries, and documentation can be found on the official Python website: https://www.python.org/ . Documentation is available in HTML, PDF, and PostScript formats at https://www.python.org/doc/ .
Python Installation
Python has been ported to many platforms. You need to download the appropriate binary for your platform or compile from source if a binary is unavailable.
Compiling from source offers more flexibility.
Unix & Linux Platform Installation
Simple steps to install Python on Unix/Linux:
Open a web browser and visit https://www.python.org/downloads/source/ .
Select the source archive for Unix/Linux.
Download and extract the archive, e.g., # tar -zxvf Python-3.6.1.tgz
Configure, build, and install: # cd Python-3.6.1 # ./configure # make && make install
Verify the installation: # python3 -V
Windows Platform Installation
Download the executable installer from https://www.python.org/downloads/windows/ . Choose the appropriate 32‑bit (x86) or 64‑bit (x86‑64) version.
During installation, check “Add Python 3.6 to PATH”. After installation, open the command prompt (Win+R, type cmd ) and run python to verify.
macOS Platform Installation
macOS includes Python 2.7 by default. Download the latest Python 3.x installer from https://www.python.org/downloads/mac-osx/ or build from source.
Environment Variable Configuration
Programs and executables may reside in directories not included in the system’s search path. The PATH variable stores these directories.
On Unix/Linux, add Python to PATH using:
<code>export PATH="$PATH:/usr/local/bin/python"</code>On Windows, add Python to PATH via the command prompt:
<code>path=%path%;C:\Python</code>Alternatively, modify the system’s Path variable through the Control Panel → System → Advanced system settings → Environment Variables.
Python Environment Variables
Variable
Description
PYTHONPATH
Search path for Python modules.
PYTHONSTARTUP
File executed on interpreter startup.
PYTHONCASEOK
Make module imports case‑insensitive.
PYTHONHOME
Alternative module search path.
Running Python
Three ways to run Python:
Interactive Interpreter
Start the interpreter from the command line:
<code>$ python # Unix/Linux</code> <code>C:\>python # Windows</code>Command‑Line Scripts
Execute a script file:
<code>$ python script.py # Unix/Linux</code> <code>C:\>python script.py # Windows</code>Ensure the script has execute permissions.
IDE (e.g., PyCharm)
PyCharm is a popular Python IDE supporting macOS, Windows, and Linux. Download it from https://www.jetbrains.com/pycharm/download/ .
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.