Overview
In some systems, especially modern Linux and macOS environments, the python command may not be available by default. When users try to run Python scripts or execute Python commands, they may encounter an error such as command not found or python: not found.
This behavior is expected and usually means that Python is installed on the system under the python3 command instead of python.
Why This Happens
Many operating systems have moved to Python 3 as the default version. To avoid confusion with the deprecated Python 2, the python command is sometimes not created automatically. As a result, users must explicitly use python3 when running Python commands.
This is common on:
-
Linux distributions such as Ubuntu, Debian, and CentOS
-
macOS systems
-
Cloud based or containerized environments
-
Minimal or hardened lab environments
How to Resolve the Issue
If you encounter an error indicating that the python command is not found, simply replace it with python3.
This ensures that you are using the correct Python interpreter that is installed on the system.
Examples
Example 1: Running a Python script
If this command fails:
python script.py
Use this instead:
python3 script.py
Example 2: Checking the Python version
If this command returns an error:
python --version
Use:
python3 --version
Example 3: Starting the Python interactive shell
If this does not work:
python
Use:
python3
Example 4: Running a one line Python command
Instead of:
python -c "print('Hello World')"
Use:
python3 -c "print('Hello World')"
Additional Notes
-
Always verify which Python version is required for your project or script.
-
Some environments may allow you to create an alias from
pythontopython3, but this depends on system permissions and is not always recommended in shared or exam environments. -
Using
python3explicitly helps avoid compatibility issues and ensures consistent behavior.
Summary
If you see an error stating that the python command is not found, it usually means Python 3 is installed but must be invoked using python3. Switching to python3 is a quick and reliable solution that works across most modern systems.