简体   繁体   中英

How do I set Python 3.11.1 as default in Linux Mint?

I'm running Linux Mint 21.1, and I'm trying to set the Python 3.11.1 interpreter as default. The problem is that I simply cannot get the command "python3" to point to my Python 3.11.1 installation.

3.11.1 is installed and fully functional in the same "/usr/lib/" directory as Python 2.7 and Python 3.10.6. I just want 3.11.1 to be the MAIN Python that is used systemwide.

I have:

  • Added Python 2.7, 3.10.6, and 3.11.1 to a group called "python" with update-alternatives and have set 3.11.1 as the default,
  • Changed the alias of the "python3" command to point to "/usr/lib/python3.11", only to find that it just echoes the directory and doesn't run the python 3.11 executable (or whatever it is called in linux),
  • Added the location of the Python 3.11.1 directory to the PATH variable.

In this process, I somehow got the command "python3.11" to start an instance of the 3.11.1 interpreter, while "python3" does the same in 3.10.6. I have no idea how or why this is happening.

None of the things I have done have worked towards my desired end. I just want "python3" to run Python 3.11.1 instead of 3.10.6, and I want this to be reflected systemwide (ie in VSCode, terminal, when running a file, etc.). I can't imagine I'm the first person to have this issue, so my question is how do I ensure that 3.11.1 is the default Python version on my system?

conda will not yet allow (succeed) to create an environment with python 3.11.1 or 3.11 because there is no package available yet for this version. See issue issue or PR

on my mint21 machine, python3 is a symbolic link in /usr/bin/ pointing to /usr/bin/pyton3.10 (you can check this via readlink -f python3 within the directory which is provided by which python3 )

personally, I wouldn't change it - but I assume you could, if you update the link via sudo ln -vfs python3 <path/to/python3.11.1/binary> (verbose, force, symbolic - details see man ln )

If your prev. attempt "just echoes the directory and doesn't run the python 3.11 executable" , I assume that you're not pointing to the binary of python3.11.1 (you can validate this via file <path/to/python3.11.1/you/used/for/the/change> - the output should mention "executable")

I do not know if mint will have a problem if you do this change. Please consider that the shipped distribution is tested and you're about to change defaults.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM