如何使Python3.7指向另一个Python解释器

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

我正在使用Ubuntu 18.04.03,最近我在系统上安装了anaconda。当前,

which python --> /home/user/anaconda3/bin/python   #good
python --version --> Python 3.7.4

which python2 --> /usr/bin/python2                 #good
python2 --version --> Python 2.7.15+ 

这很好。但是,

which python3 --> /home/user/anaconda3/bin/python3  #oh no
python3 --version --> Python 3.7.4                  #oh no again

#python3.6.8 has been installed in /usr/bin/python3.6
#python3 needs to point /usr/bin/python3.6

这不好。另外

which python3.7 --> /home/user/anaconda3/bin/python3.7  #please no
python3.7 --version --> Python 3.7.4                  

#python3.7 has been installed in /usr/bin/python3.7
#python3.7 needs to point /usr/bin/python3.7 not anaconda's 3.7

不好。

[您可能知道,当我编写python (some version)时,我想在/usr/bin中调用解释器而不是anaconda的解释器,只有当我只编写python时,我想调用anaconda的解释器。我该如何实现?

python ubuntu anaconda python-3.7
2个回答
1
投票

$PATH检查echo $PATH环境变量的内容。在输出中找到anaconda bin目录,然后在外壳程序脚本($PATH/etc/bash_profile.bashrc.bash_profile)中更改bash,将其放置在/usr/bin之后。您可能需要使用ln -s创建符号链接,以便继续使用anacondapythonpython2


0
投票

您可以尝试更改python3.7指向的别名

echo 'alias python3.7="/usr/bin/python3.7"' >> ~/.bashrc

然后

source ~/.bashrc
© www.soinside.com 2019 - 2024. All rights reserved.