Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python command not found on Linux [closed]

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

When type python3 on the terminal I get:

python 3.9.0

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

bash: python: command not found

And this happens to every Python program I try to install on my machine.

like image 919
Ziad Alian Avatar asked Apr 16 '26 05:04

Ziad Alian


2 Answers

I had the same error too with Ubuntu 20.04, in the case you like "python" to refer to "python3", you can simply install python-is-python3:

sudo apt-get install python-is-python3

After this, invoking python will work just fine

I verified this solution only with Ubuntu 20.04 (18.x has not this package)

like image 196
Fabiano Tarlao Avatar answered Apr 18 '26 18:04

Fabiano Tarlao


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.

like image 42
vivek kumar Avatar answered Apr 18 '26 17:04

vivek kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!