How to configure Python version in Ubuntu
How to configure the Python version in Ubuntu, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
First check which versions of Python are available in the system.
Ls / usr/bin/python
View the current python version
Python-version
Modify the default version based on the user
To modify the Python version for a particular user, simply create an alias (alias) under its home directory. Open the user's ~ / .bashrc file and add new alias information to modify the default version of Python.
Alias python='/usr/bin/python3.6'
Once you have done this, log in again or reload the .bashrc file for the operation to take effect.
. ~ / .bashrc
Modify the Python version at the system level
Use update-alternatives to change the Python version for the entire system. To log in as root, first list all available python alternative version information:
Update-alternatives-- list pythonupdate-alternatives: error: no alternatives for python
If the error message shown above appears, the alternative version of Python has not been recognized by the update-alternatives command. To solve this problem, we need to update the alternative list to include python2.7 and python3.6.
Update-alternatives-- install / usr/bin/python python / usr/bin/python2.7update-alternatives-- install / usr/bin/python python / usr/bin/python3.6
The-- the install option uses several parameters to create symbolic links. The last parameter specifies the priority of this option, and if we do not set the alternative manually, the option with the highest priority will be selected. In this example, we set the priority for / usr/bin/python3.6 to 2, so the update-alternatives command automatically sets it to the default Python version.
Python-version
At this time, the version is already python 3.6.
Next, we list the available alternative versions of Python again.
Update-alternatives-list python/usr/bin/python2.7/usr/bin/python3.6
From now on, we can use the command below to switch between the listed alternative versions of Python at any time.
Update-alternatives-config python
Remove alternate version
Once an alternative version of Python no longer exists on our system, we can remove it from the update-alternatives list. For example, we can remove the python2.7 version from the list.
Update-alternatives-remove python / usr/bin/python2.7
Method 2. Remove the soft connection
Rm-rf / data/logs ln-s / temp/logs / data/logs this is the answer to the question about how to configure the Python version in Ubuntu. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.