Table Of Contents
Problem
You get "python: command not found" or "python is not recognized" error when trying to run Python from command line.
Solution
# Check Python installation
python3 --version
# If python3 works, create alias for python
echo 'alias python=python3' >> ~/.bashrc
source ~/.bashrc
# Or add to PATH (Linux/macOS)
export PATH="/usr/bin/python3:$PATH"
# Windows - Add Python to PATH
# Go to System Properties > Environment Variables
# Add Python installation directory to PATH
# Install Python if not installed
# macOS with Homebrew
brew install python
# Ubuntu/Debian
sudo apt update && sudo apt install python3
# Verify installation
python --version
which python
Explanation
The error occurs when Python isn't installed or not in your system's PATH. Use python3
instead of python
on most systems, or create an alias.
On Windows, ensure Python installation directory is added to PATH environment variable during installation or manually add it afterwards.
Share this article
Add Comment
No comments yet. Be the first to comment!