升级到Python 3.10,不同的用户 - python3 别名指向相同的二进制文件,但显示不同的版本

问题描述 投票:0回答:1

在基于 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 的: enter image description here

如何让jenkins用户的

python3
命令永久指向版本3.10

python linux bash shell debian
1个回答
0
投票

故障排除

  • 检查
    alias type python
    :它可能是指向另一个版本的别名。检查你的 shell 配置文件
    ~/.bashrc
  • 如果已安装,请尝试
    pyenv versions
    。如果没有,请尝试一下,因为这是管理多个版本的好方法。设置默认值并具有不同版本的项目特定环境。

解决方案

如果上述方法均不起作用,请确保已安装 python 3.10 并执行以下操作:

  • echo 'alias python3=python3.10' >> ~jenkins/.bashrc
  • source ~jenkins/.bashrc
  • 检查
    su jenkins
    python3 --version
© www.soinside.com 2019 - 2024. All rights reserved.