Sunday, February 27, 2022

[SOLVED] python command not found on linux

Issue

I have a problem while running python on linux, I have python3 already installed.

When type python3 on the terminal i got:

python 3.9.0

When I run any program I made with for example python I got this error

bash: python: command not found

And this happen to every python program I try to install on my machine.


Solution

Place the below line in ~/.bashrc file:

alias python=python3

After inserting run the below command:

source ~/.bashrc

.bashrc is the configuration file for bash, a linux shell/command interpreter. An alias is a substitute for a (complete) command. It can be thought of as a shortcut. By adding the above line, an alias is created for python3 in the name of python. Now the programs using python instead of python3 should work fine without any error.



Answered By - vivek kumar
Answer Checked By - Mary Flores (WPSolving Volunteer)