P2-7.7 Supplemental Learning: When Is Python Installation Needed?¶
Section ID:
P2-7.7Version:v2026.09.15
A hosted Colab runtime does not require Python on your computer. Running .py files or processing local files on your own computer requires a local interpreter. Python may already be installed, so first check execution commands and versions.
Official Installation Manual Links¶
Link collection date: 2026-07-20
Installation screens and recommended methods can change over time. When actually performing an installation, do not look only at this section. Check the official documents below together with it.
- Overall installation and usage guide: Python Software Foundation, Python Setup and Usage.
- Download page: Python Software Foundation, Download Python.
- Installation and execution on Windows: Python Software Foundation, Using Python on Windows.
- Installation and execution on macOS: Python Software Foundation, Using Python on macOS.
- Usage on Linux/Unix platforms: Python Software Foundation, Using Python on Unix platforms.
- Virtual environments: Python Software Foundation, venv — Creation of virtual environments.
Hosted Colab Runtimes¶
In early learning, Colab is often enough.
- running simple Python code
- checking NumPy array calculations
- handling small table data
- quickly drawing graphs
- following example code from the book cell by cell
The browser handles code input and result display, while the hosted runtime executes Python code. These tasks can be done without installing Python locally.
Colab is not your own computer. Its runtime is provided by an external service, sessions can be reset, and persistent file and package state is not guaranteed.
Tasks Requiring a Local Interpreter¶
Local Python is needed to perform these tasks on your own computer:
- Run
.pyfiles from a terminal or editor. - Read local data files and save results on the same computer.
- Create project virtual environments and manage packages.
- Run Python calculations without an internet connection.
Having multiple files or a Git repository does not by itself require local execution. Projects and packages can also be managed in remote runtimes. The deciding factor is where the code will actually run, not the number of files.
Python Installation and Command Setup¶
Python installation is the act of preparing the Python interpreter on my computer. The official Python documentation separately guides platform-specific Python environment setup, interpreter execution, and information that makes work easier.
Once installation, command setup, and required components are ready, the following become possible.
- You can run Python commands in the terminal.
- You can run
.pyfiles with Python. - You can install packages through
pip. - You can create virtual environments.
But installation alone does not finish everything.
Even after installing Python, the following problems may remain.
- The
pythoncommand may not work in the terminal. - On macOS/Linux, you may need to use the
python3command. - On Windows, you may encounter the
pycommand. - Multiple versions of Python may be installed.
- If you do not use virtual environments, project-specific packages may get mixed together.
So right after installation, instead of stopping at “it was installed,” you must check “which command points to which Python?”
Checking the Python Version for Each Command¶
Check the following command in the terminal.
On macOS or Linux, the following command may be more natural.
On Windows, depending on the Python installation method, you may encounter the following command.
Even if one of these works, that does not mean the others necessarily work. What matters is checking which command in my environment runs the Python interpreter.
If no version is printed, check installation and command setup before the code. Different commands may print different versions, so choose the Python to use for the project.
Windows Installation Options¶
The official Python Windows documentation explains that unlike most Unix systems, Windows does not include a system-supported Python installation by default. It says Python can be obtained from several distributors, and that to use the CPython team's distribution, you can use Python Install Manager.
Check the following for installation and execution.
- Windows may not have a reliable system Python you can assume exists.
- Python can be installed through the python.org download page or through Microsoft Store.
- After installation, check whether the
pythonandpycommands work. - The official documentation recommends creating a virtual environment for each project.
If Python is installed but the command cannot be found, check the installation path, execution aliases, and PATH settings. The Troubleshooting section of the official Windows documentation lists checks for each installation method.
macOS Installation Options¶
The official Python macOS documentation explains that there are several ways to get and install Python on macOS, and that there may be distributions other than the installer package provided on python.org. Current supported Python versions provide macOS installer packages on python.org.
Check the following for installation and execution.
- macOS may contain Python-related components used by system tools, so do not modify the system area carelessly.
- For learning Python, use the python.org installer package or another well-known distribution method.
- In the terminal, people often check
python3 --versionfirst. - Even after installation, it is safer to separate project practice with virtual environments.
The macOS documentation explains that running scripts in the terminal and running them from Finder can differ. Running them while checking the current folder in the terminal is more transparent.
Distribution Python on Linux¶
The official Python Unix-platform documentation explains that Python is preinstalled in most Linux distributions, and even when it is not, it is provided as a package.
Check the following for installation and execution.
- On Linux,
python3 --versionmay already work. - Python is often managed through the distribution's package manager.
- System Python may be used by operating-system tools, so do not delete or modify it carelessly.
- For project practice, it is safer to create a virtual environment and separate it.
In Linux materials, you may see commands like sudo apt install python3. But the package manager and package names can differ by distribution. Therefore, Linux installation commands should be checked against the official documentation of your own distribution.
Interpreter, Virtual Environment, and Packages¶
Python installation and virtual-environment creation are not the same thing.
| Category | What it does | Example |
|---|---|---|
| Python installation | Prepares the Python interpreter on the computer | python.org installation, OS package installation |
| virtual-environment creation | Creates a Python execution space for a particular project | python -m venv .venv |
| package installation | Prepares external packages in that environment | python -m pip install numpy |
The official Python venv documentation explains that when a virtual environment is activated, the path is prefixed so that the Python interpreter from that environment is run. It also warns that virtual environments should be recreatable when needed, and that packages should be reinstallable using records such as requirements.txt.
Prepare the project environment in this order.
- Install Python.
- Move to the project folder.
- Create a virtual environment.
- Activate the virtual environment or directly specify its Python path.
- Install the needed packages.
- Run the Python code.
Checking Installation and Execution Environments¶
When Python installation gets tangled, do not jump straight to reinstalling. Check these things first.
- Which terminal did I open now?
- Where is the current working folder?
- Does
python --versionwork? - Does
python3 --versionwork? - If on Windows, does
py --versionwork? - Are multiple Python versions installed?
- Is a virtual environment currently turned on?
- Is the Python where packages were installed the same Python that is running the code?
The following situations are especially common.
- You installed packages into system Python, but you are running with virtual-environment Python.
- You installed packages into the virtual environment, but you are running after turning the virtual environment off.
- You assume that a package installed in Colab is also installed on the local PC.
- On Windows,
pythondoes not work, butpydoes. - On macOS/Linux,
pythonis missing or points to Python 2, whilepython3points to the real Python 3.
When reading error messages, you need the habit of separating “Python code error” from “execution-environment error.”
Does One Missing Command Require Reinstallation?¶
Suppose a Linux terminal shows the following. The version number only illustrates the output format.
This environment has no command named python, but it has an interpreter run by python3. Before reinstalling, you can run a script with python3 example.py or create a project environment with python3 -m venv .venv.
If none of the relevant Python commands is available and local execution is needed, follow the installation procedure for the operating system. Distinguishing one failed command from an absent interpreter avoids unnecessary reinstallation.
Components to Check After the Version¶
Version output confirms that the interpreter can run. Check the project’s supported Python range and package compatibility before choosing a version, rather than selecting solely because it is newest. Once the Python command is chosen, check pip through that same command.
These are alternatives for environments where python3 or py works. No module named pip means pip is absent from the selected Python, not that Python itself is missing. An ensurepip-related error during venv creation on Linux may indicate a separately packaged virtual-environment component. Check the operating system or distribution’s official instructions for that component, then resume virtual-environment creation in P2-7.4.
Checklist¶
- You can explain the difference in roles between Colab and local Python installation.
- You can judge when local installation is needed.
- You can explain the purpose of
python --version,python3 --version, andpy --version. - You can explain that Python installation methods may look different on Windows, macOS, and Linux.
- You can distinguish Python installation, virtual-environment creation, and package installation.
- You can explain that when an installation error occurs, the execution environment should be checked before the code.
- You can check
which command runs Python in my terminal,which Python version that command points to,whether I am ready to create a project-specific virtual environment, andwhether the package-installation environment and code-execution environment are the same.
Sources and References¶
- Python Software Foundation, Python Setup and Usage, Python 3 documentation, checked 2026-07-20. Used to confirm the documentation structure for platform-specific Python environment setup, interpreter invocation, and installation guidance.
- Python Software Foundation, Download Python, Python.org, checked 2026-07-20. Used to confirm the latest Python download and operating-system-specific download entry points.
- Python Software Foundation, Using Python on Windows, Python 3 documentation, checked 2026-07-20. Used to confirm that Python installation and execution on Windows has separate official guidance.
- Python Software Foundation, Using Python on macOS, Python 3 documentation, checked 2026-07-20. Used to confirm the python.org distribution and post-installation package-use guidance on macOS.
- Python Software Foundation, Using Python on Unix platforms, Python 3 documentation, checked 2026-07-20. Used to confirm that Linux/Unix installation paths can differ by operating system, such as distribution packages or source builds.
- Python Software Foundation, venv — Creation of virtual environments, Python 3 documentation, checked 2026-07-20. Used to confirm that project-specific virtual environments may be created as a separate step from installing Python itself.