在基于 Debian 11 的 docker 容器中,我有点困惑为什么
root
和 jenkins
用户的 python3
命令指向相同的二进制文件但具有不同的版本:
sh-5.1$ whoami
jenkins
sh-5.1$ python3 --version
Python 3.9.2
sh-5.1$ which python3
/usr/bin/python3
sh-5.1$
exit
root@c5891e24911a:/home/jenkins#
root@c5891e24911a:/home/jenkins# whoami
root
root@c5891e24911a:/home/jenkins# which python3
/usr/bin/python3
root@c5891e24911a:/home/jenkins# python3 --version
Python 3.8.16
我尝试将
.bachrc
中的版本更改为 3.10,但我想它不起作用,因为那是针对非登录 shell 的:
如何让jenkins用户的
python3
命令永久指向版本3.10?
alias type python
:它可能是指向另一个版本的别名。检查你的 shell 配置文件~/.bashrc
。pyenv versions
。如果没有,请尝试一下,因为这是管理多个版本的好方法。设置默认值并具有不同版本的项目特定环境。echo 'alias python3=python3.10' >> ~jenkins/.bashrc
source ~jenkins/.bashrc
su jenkins
python3 --version