Fix Python Command Not Found Error in Linux


This article supplies directions to mend the mistake “Python command not found” in Linux.

After following the stairs described on this instructional, you are going to get your Python bundle mounted. The content material under mentions all conceivable reasons of this downside, reported by way of many Linux customers.

All steps proven come with screenshots to make it simple for each Linux consumer to put into effect them. Despite this record being in line with Debian/Ubuntu Linux distributions, maximum steps are common and legitimate for all distributions.”

The strategies defined to mend the “Python command not found” error on this article come with:

  • Installing Python (Debian, Ubuntu, CentOS, Fedora)
  • Checking the PATH variable
  • Fixing Python comfortable/symbolic hyperlinks


This instructional makes a speciality of the Python3 bundle, in spite of it together with directions to put in Python2 for customers with explicit wishes.

Python 3 is the present model, being earlier variations discontinued. If you don’t have any explicit wishes with outdated Python variations, please simplest apply the stairs to get Python 3 running and forget about Python 2-related instructions.

Also, it’s price bringing up prior to proceeding studying more than likely; you’re working the python command as an alternative of the present python3 command; if python3 works and you need it to be accomplished when typing python, it’s possible you’ll need to bounce to the ultimate segment of this record.

Step 1: Make Sure Python is Installed and How to Install it

The first step to diagnosing this mistake is to test if Python is correctly put in for your device.

One of the tactics to test that is by way of printing all Python directories beneath /usr/bin the use of a wildcard, as proven under.

Another means is by way of executing the command, as proven within the following screenshot.

which python python2 python3

In case the output does now not display the Python model you wish to have, on Debian/Ubuntu primarily based techniques, run the next command to replace repositories previous to set up (Keep studying under for different Linux distribution directions).

To set up Python 3, run the command proven within the determine under.

sudo apt set up python3 -y

Only if you’re on the lookout for Python earlier model (Python 2), run the next command.

sudo apt set up python2 -y

To set up Python3 on CentOS, run:

And then execute:

For Python2 on CentOS, execute:

To set up Python3 on Fedora, execute the next:

For Python2 run:

sudo dnf set up -y python2

After putting in Python, test if the command now not discovered error persists. If it helps to keep appearing up, take a look at the stairs described under.

Step 2: Checking the PATH Variable

If Python is put in for your device, however it isn’t discovered when executing Python instructions, more than likely your downside is the PATH atmosphere variable.

You should test if the trail /usr/native/bin is incorporated within the PATH variable.

To test the PATH atmosphere variable, run the next command.

As you’ll be able to see, the former command returns paths separated by way of a colon. Make certain the trail /usr/bin is incorporated. If now not, then execute the command proven within the determine under.

export PATH=$PATH:/usr/bin

If the former command helped and Python works, your downside was once within the PATH variable. But the prior to now accomplished command isn’t power, and the trail shall be incorporated simplest within the present consultation.

To resolve the issue completely, upload the trail to the .bashrc record beneath your own home listing.

Open it the use of any textual content editor you need; in my case, I take advantage of nano, as proven under.

At the top of the record, upload the road proven under.

export PATH=“$PATH:/usr/bin”

Close the .bashrc record saving settings and replace the trail variable by way of working the next command.

If the PATH variable didn’t repair the issue, you’re more than likely coping with a symbolic hyperlink factor.

In some instances, the mistake motive could also be a flawed or absent symbolic or comfortable hyperlink.

The bundle python-is-python3 creates a symbolic hyperlink between Python and Python3 for Python3 to be accomplished when the consumer runs Python. After putting in this bundle, working the command python will execute python3.

The first content material of this segment displays methods to unravel this downside on Debian and Ubuntu Linux distributions by way of putting in the discussed bundle. The 2nd segment explains methods to manually upload the symbolic hyperlink, legitimate for just about each Linux distribution.

To set up the python-is-python3 bundle on Debian or Ubuntu Linux distributions, run the next command.

sudo apt set up python-is-python3

Once put in, test if the comfortable hyperlink was once correctly outlined by way of working the command proven within the following determine.

To see Python-related symbolic hyperlinks, run the command described under.

Once the Python actual model, the syntax so as to add a comfortable hyperlink is the next:

sudo ln -fs /usr/bin/pythonVersion> /usr/bin/python

For instance, if the Python 3 model is 3.9, I’d run:

sudo ln -fs /usr/bin/python3.9 /usr/bin/python


As you’ll be able to see, this not unusual error has 3 primary conceivable causes. Installing Python, defining the right kind trail, or solving symbolic hyperlinks are answers any Linux consumer can observe independently of the data degree. In some instances, if the mistake persists, take a look at purging all Python-related applications and putting in them again. In maximum instances, if now not all, all of the answers supplied on this article will have to repair the problem. The steps are legitimate for just about each Linux distribution. While some steps (Like set up) center of attention on Debian/Ubuntu, CentOS and Fedora, putting in the similar applications the use of your distribution applications supervisor is an identical. I am hoping this content material was once helpful so that you can get Python running.

Thank you for studying this instructional explaining methods to repair the mistake “Python command not found” in Linux. Keep following us for extra skilled articles.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More