bash: python: command not found

Python command not found after installing Python3? Fix it

Linux & Unix Beginner 👁 10 views 📅 Jun 20, 2026

You installed Python3 but the 'python' command still doesn't work. Here's how to get it running in under 5 minutes.

The 30-second fix - Check if it's just a name issue

Most Linux distros now ship with python3 instead of python. That's intentional, not a bug. First, see if Python3 is actually there:

which python3

If it shows something like /usr/bin/python3, you're good. The fix is dead simple: create an alias or symlink.

Option A: Alias (no permissions needed)

Add this to your ~/.bashrc or ~/.zshrc:

alias python='python3'

Then run source ~/.bashrc. Now python will work. But it only works for your user. If you want system-wide, use Option B.

Option B: Symlink (need sudo)

This makes the python command work for everyone and all scripts. Run:

sudo ln -s /usr/bin/python3 /usr/local/bin/python

Test it:

python --version

Last week I had a client whose whole cron job pipeline broke because they used python in scripts. This fixed it in 30 seconds.

The 5-minute fix - Check PATH and install missing packages

If the symlink didn't work or python3 isn't found, the problem is deeper. Let's check your PATH and whether Python3 is actually installed.

Step 1: Is Python3 installed at all?

dpkg -l | grep python3

If nothing shows, install it:

sudo apt update
sudo apt install python3

Step 2: Check your PATH

echo $PATH

Look for /usr/bin or /usr/local/bin. If you installed Python3 manually (say from source), it might be in /usr/local/bin. If that's not in PATH, add it to ~/.bashrc:

export PATH=$PATH:/usr/local/bin

Step 3: Use update-alternatives (Debian/Ubuntu)

This is the cleanest way to set the default python command. Many distros ship with python3 but not python to avoid conflicts with Python 2. Here's the right way:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo update-alternatives --config python

If you have multiple Python versions, this lets you switch between them easily. I've used this on Ubuntu 22.04 and Debian 12 - works every time.

The 15+ minute fix - Compile from source or fix broken packages

If nothing above worked, something went wrong with your install. Maybe you compiled Python from source and it's somewhere weird, or your package manager is corrupted. Let's fix it proper.

Step 1: Remove any broken Python installations

First, find where Python3 actually is:

find /usr -name 'python3*' -type f 2>/dev/null

If it's in /usr/local/bin, check for multiple versions:

ls -la /usr/local/bin/python*

Had a client once who had Python 3.9 in /usr/local and Python 3.11 in /usr/bin - total mess. Clean it up:

sudo apt remove --purge python3
sudo apt autoremove
sudo rm -rf /usr/local/bin/python* /usr/local/lib/python*

Then reinstall fresh:

sudo apt update
sudo apt install python3 python3-pip

Step 2: Rebuild from source (if needed)

If you need a specific Python version that's not in your repos (like Python 3.12 on Ubuntu 20.04), you might need to compile. But don't do this unless you have to - it's a pain. Use deadsnakes PPA instead:

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12

Then create the symlink as above. This is much cleaner than compiling from source and your package manager stays happy.

Step 3: Verify everything works

python --version
which python
python3 --version

Both should work and point to the same version. If python --version still fails, double-check your PATH and symlinks.

One more thing - pip might also be missing

If you got Python working but pip doesn't work, install pip for Python3:

sudo apt install python3-pip

Then alias pip too:

sudo ln -s /usr/bin/pip3 /usr/local/bin/pip

Or use update-alternatives:

sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1

That's it. You should be running Python from the command line now. If not, check if you're in a virtual environment or container that's stripping PATH - that's a whole different ballgame. But 9 times out of 10, the symlink or alias fix does it.

Was this solution helpful?