简体   繁体   English

如何通过别名在 Linux 中将默认的 python3 设置为 python3.9?

[英]How to set the default python3 to python3.9 in Linux via aliases?

I'm a newcomer to the world of Linux.我是 Linux 世界的新手。 I've installed a distro in a virtual machine (elive, to be precise) and I'm starting to play around a bit.我已经在虚拟机中安装了一个发行版(准确地说是活的),我开始玩了一下。 I've built from source the latest python version (3.9 at the time of writing).我从源代码构建了最新的 python 版本(撰写本文时为 3.9)。 Now I'm trying to set it as the default python3 version (at the moment the default version is python3.2).现在我正在尝试将其设置为默认的python3版本(目前默认版本是python3.2)。 It suffices to be set this way just for my personal shell.只为我个人的 shell 设置这种方式就足够了。 I've read about aliases, so I tried to use them to set the default python version.我读过别名,所以我尝试使用它们来设置默认的 python 版本。 I wrote in the.bashrc the following line:我在 .bashrc 中写了以下行:

alias python3='python3.9'

I also tried:我也试过:

alias python3=python3.9
alias python3="/usr/local/lib/python3.9"

I've also read that you might need to login again, so I tried it but with no results.我还读到您可能需要再次登录,所以我尝试了但没有结果。 What am I doing wrong?我究竟做错了什么?

Thank you for your help in advance.提前谢谢你的帮助。

If you want better is update alternatives with this you can change default editor etc.如果您想要更好的是更新替代品,您可以更改默认编辑器等。

How to select which version of python I am running on Linux? 如何 select 我在 Linux 上运行哪个版本的 python? - Stack Overflow - 堆栈溢出

How to change from default to alternative Python version on Debian Linux - LinuxConfig.org 如何在 Debian Linux 上从默认更改为替代 Python 版本 - LinuxConfig.org

or you can try this Gui version或者你可以试试这个 Gui 版本

sudo apt install galternatives

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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