DebugPointer
Published on

Symlink python3 command to latest python version

Symlink python3 command to latest python version

Symlink python3 command to run python 3.10 (or any latest python versions)

First check which python version you need by running-

$ ls /usr/bin/python3*
/usr/bin/python3    /usr/bin/python3.5-config  /usr/bin/python3.5m-config  /usr/bin/python3.7-config  /usr/bin/python3.7m-config  /usr/bin/python3.10-config  /usr/bin/python3m
/usr/bin/python3.5  /usr/bin/python3.5m        /usr/bin/python3.7          /usr/bin/python3.7m        /usr/bin/python3.10          /usr/bin/python3-config    /usr/bin/python3m-config

Now, to symlink python 3.10 to python, execute the following command in your shell-

$ ln -sf /usr/bin/python3.10 /usr/bin/python3

The above command would have added a symlink of python3.10 to python3. To verify the same, you can run the command-

$ /usr/bin/python3 --version
Python 3.10.2

or even run the python3 command directly to check if the symlink works for Python 3.10-

$ python3 --version
Python 3.10.2

Symlink python3 command to run python 3.10

Similarly to symlink python 3.10 to python, execute the following command in your shell-

$ ln -sf /usr/bin/python3.10 /usr/bin/python3

The above command would have added a symlink of python3.10 to python3. To verify the same, you can run the command-

$ /usr/bin/python3 --version
Python 3.10.0

or even run the python3 command directly to check if the symlink works for Python 3.10-

$ python3 --version
Python 3.10.0

As I've discussed ways to symlink any latest python version to python3 seamlessly, you can symlink to any version of your choice with the above commands.