python command not found - Ubuntu
How to Install Python Command on Ubuntu
If you are using Ubuntu and trying to run the python command in your terminal, you may encounter an error stating that the command is not found. This can happen because Ubuntu does not come pre-installed with the Python command line tool by default.
What is the Python Command?
The python command is a command line tool that allows you to run Python scripts and interact with the Python interpreter directly from the terminal. It is essential for Python developers and anyone working with Python code.
Installation on Ubuntu
To install the python command on Ubuntu, you can follow these steps:
-
Open your terminal by pressing
Ctrl + Alt + T. -
Update your package list to ensure you have the latest information about available packages:
sudo apt update -
Install the
python-is-python3package, which provides thepythoncommand on Ubuntu:sudo apt install python-is-python3 -
After the installation is complete, you can verify that the
pythoncommand is now available by running:python --version -
You should see the Python version installed on your system, confirming that the
pythoncommand is now working.
Compatibility Note
In newer versions of Ubuntu, the python command has been replaced by python3 to differentiate between Python 2 and Python 3. If you are using a version of Ubuntu where python points to Python 2, you can still use python3 for Python 3 scripts.
Conclusion
By following the steps outlined in this tutorial, you can successfully install the python command on Ubuntu and start using it to run Python scripts and interact with the Python interpreter in your terminal. Remember to adapt to the changes in Python versions and commands to ensure compatibility with your system.