Resolving: python not found on Ubuntu fixed
Introduction
In this tutorial, How to solve problem python not found on Ubuntu.
Python, a widely-used programming language, serves as the backbone for numerous applications and scripts across various domains. Ubuntu, a popular Linux distribution, usually comes pre-installed with Python.
However, there might be instances where the system fails to recognize the Python installation, leading to the dreaded "Python not found" error. This article explores the common reasons behind this issue and provides step-by-step solutions to fix it on an Ubuntu system.
I run a python program in the Linux terminal as below:
python script.shUse python command in Ubuntu or some other distributions will throw an error as below:
vagrant@controller:~$ python
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
The python command is actually python3 here. Because the Python package is not installed as python but python3 or python2
When Python version 3 released, distributions start both python2 and python3. Python 2 is no longer supported and Python 3.x get on Ubuntu.
How to python not found on Ubuntu fixed
To check Python version 3 installed on your server as the picture as below:
If you don't have any python verion, you need install python version 3 as command below:sudo apt install python3
Use python3 instead of python
To check version
python3 --versionrun a python program
python3 script.sh
Link python3 as python
you can create a permanent in your .bashrc file
alias python='python3'
For Ubuntu 20.04 and higher versions, you have a package that does all link creation automatically if you install the python-is-python3 package.
sudo apt install python-is-python3
You can see that symbolick link have been created and you can use the python command
Conclusion
Encountering the "Python not found" error on Ubuntu can be frustrating, but it's often due to minor configuration issues. This article outlines steps to diagnose and fix the problem easily. Whether it's a missing installation, incorrect PATH variable, virtual environment hiccup, or corrupted setup, the solutions provided should get Python running smoothly on your Ubuntu machine again. I hope this is helpful to you. Thank you for reading the huuphan.com page!
Comments
Post a Comment