Python 3 Installation and Running Guide
From Excel batch processing for automated office work, to dashboard generation for data visualization, to lightweight fine-tuning scripts for large AI models - Python is the tool chain language of choice for almost every technology beginner and development veteran. Today we will start with the most basic environment-setup and code running methods to clear the first stumbling block for getting started with Python.
Install Python 3
Currently, Python still has two major version branches, 2.x (official maintenance has stopped) and 3.x (currently mainstream). This article is explained based on the latest stable version of Python 3.x. Please be sure to choose the 3.x branch for installation.
Windows system installation
Method 1: Official pure installation package (suitable for lightweight entry)
- Visit Python 官方下载中心
- The system will automatically identify your Windows bit number, just download the recommended Windows installer (64-bit) (please choose the corresponding version for 32-bit old devices)
- Key steps ⚠️: Open the first page of the installation program. **You must check "Add Python X.
- Click "Install Now" to complete it with one click (the default configuration is friendly enough for novices)
Method 2: Anaconda full-stack package (recommended for AI/data analysis direction)
Anaconda is a one-stop environment package that includes Python, commonly used data science libraries (such as Pandas, NumPy) and development tools, and is universal across platforms:
- Visit Anaconda 官网下载页
- Select the free Individual Edition of the corresponding platform and download and install it.
macOS system installation
Method 1: Official pure installation package
- Also download the macOS version from Python 官方下载中心
.pkgBag - Double-click to run and follow the wizard's default "Continue" to complete the installation.
Method 2: Homebrew package manager (recommended for macOS technical users)
Homebrew is the most commonly used command line software management tool for macOS. If you haven’t installed it yet, you can run it in the terminal first:
After installing Homebrew, get the latest stable version of Python 3 with one click:
Linux system installation
Most modern Linux distributions (such as Ubuntu 20.04+, Fedora 36+) come with Python 3 pre-installed by default, but the version may be older or missing some necessary components. If you need to upgrade/reinstall, you can choose the corresponding command according to the release version:
Debian / Ubuntu Series
Fedora / RHEL / CentOS Stream Series
Arch Linux / Manjaro Series
Verify whether the installation is successful
After the installation is complete, we need to confirm Python and package management tools in Terminal/Command Linepipcan be called normally.
View Python version
- Windows (used by default after clean installation)
python): - macOS / Linux:
If it shows something likePython 3.12.1The specific version number indicates that the installation is successful!
Check pip version
- Windows:
- macOS / Linux:
Tip: If
pipNot recognized, you can run it firstpython -m pip --versionSee if it can be called normally.
Two mainstream ways to run Python
Python provides two methods: interactive real-time testing and script file batch running, which are suitable for different scenarios.
1. Interactive REPL environment (suitable for learning and testing small codes)
The full name of REPL is "Read-Eval-Print Loop", which means read-execution-output loop. You enter a line of code and it will give the result immediately.
Enter REPL
- Windows:
- macOS / Linux:
After successfully logging in, you will see the terminal appear>>>prompt (this is Python's interactive flag), you can now write code directly for testing:
Exit REPL
There are two methods:
- Enter built-in functions
exit()orquit()and press Enter - Shortcut key operations:
- Linux / macOS:
Ctrl + D - Windows:
Ctrl + Zand then pressEnter
- Linux / macOS:
2. Batch running of script files (suitable for actual projects and formal codes)
You should use it when the code exceeds 3-5 lines or needs to be saved and executed repeatedly..pysuffixed script file.
Step 1: Create a script file
Open any plain text editor (VS Code, Notepad, TextEdit are all acceptable, Be careful not to use rich text editors such as Word/WPS), enter the following code and save it ashello.py:
Step 2: Execute the script file
Open the terminal/command line and switch to the folder where the script file is located (for example, if you puthello.pyplaced on the desktop), then run:
- Windows:
- macOS / Linux:
After execution you will see two neat lines of output!
Quick FAQ for newbies
Question 1: Prompt "python / python3 is not an internal or external command"
This is because the system cannot find the installation path for Python and can be solved by platform:
- Windows Clean Installation: Re-open the official installation package, select "Modify" to modify, check "Add Python X.
- macOS/Linux: First confirm whether the installation is successful (try the installation command corresponding to the system again). If it still does not work, try to use the complete installation path call (for example, the default path for macOS Homebrew installation is
/usr/local/bin/python3)
Question 2: There are multiple Python versions on the computer, how to switch?
- Windows: The official installation package will automatically include one
pyLauncher, you can switch by specifying the version number: - macOS/Linux: It is recommended to use the pyenv tool for professional multi-version management. For installation and use, please refer to pyenv 官方文档
Must-have development tools and techniques for getting started
1. Recommended code editor
- The first choice for lightweight entry: VS Code + Python extension (search "Python" in the plug-in store and install the official Microsoft one), supports syntax highlighting, auto-completion, and one-click operation
- The first choice for full-stack Python development: PyCharm Community Edition (free version), which comes with powerful project management, debugging, and code refactoring functions
2. Virtual environment: an artifact to isolate project dependencies
If you are working on multiple Python projects at the same time, each project may require different third-party library versions (for example, project A requires Pandas 1.5, and project B requires Pandas 2.0). At this time, you need to use virtual environment to isolate the dependencies of each project to avoid conflicts.
Create and activate virtual environment
- Open Terminal in the project folder
- Create a virtual environment (
myenvIt is the name of the virtual environment and can be changed at will): - Activate virtual environment:
- Linux / macOS:
- Windows(CMD):
- Windows(PowerShell):
- Linux / macOS:
After activation, the terminal will appear at the beginning(myenv)sign, indicating that you are now in the virtual environment!
4. Exit the virtual environment:
Summarize
Today we have completed the full process of getting started with Python 3:
- Install the latest stable version of Python 3, Be sure to remember to check "Add to PATH"
- Learned to verify installation in two ways
- Mastered the two core operating methods of "interactive REPL testing small code" and "script file running formal code"
- Understand the solutions to common problems faced by novices and the necessary virtual environment for getting started.
Now, you are ready to start your Python programming journey!

