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.
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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With