I had both python3.8 and python2.7 installed on a Linux system (Ubuntu in this case, but this solution should work for other flavours of Linux too), however running python --version
gave a python: command not found
response.
Steps to resolve:
-
Verify if any version of python was installed on the system
- I wanted to be sure that the system had some version of python installed. Using
whereis python3
orwhereis python2
command shows the versions and paths of python installed on the system. The output should look something like this
- I wanted to be sure that the system had some version of python installed. Using
If there is no version of python installed, install it using
sudo apt-get install python3.8
orsudo apt-get install python<version>
(useyum
instead ofapt-get
for RHEL)cd to /usr/bin folder and create a symlink to the version of python you want to be invoked using the python command.
Example:
cd /usr/bin
ln -s /usr/bin/python3.8 python
Verify the if the symlink is created usingls -l python
and verify if the python command works and is pointing to the right version of python usingpython --version
.
Top comments (0)