【发布时间】:2020-06-09 04:26:32
【问题描述】:
我在 x86-64 Linux 大型机上创建了一个新的 Conda 环境,使用命令
conda create --name myenv --file somefile.txt --python=3.8.
我在这个环境中使用conda list 仔细检查了我的 Python 版本,结果返回
...
python 3.8.3 hcff3b4d_0
...
但是,激活此环境后,Python 3 脚本无法运行,运行which python 表明该环境默认使用默认系统 Python 2 解释器:
$ which python
/usr/bin/python
到目前为止我的努力
首先,我将export PATH=$PATH:/home/miniconda3/envs/myenv/bin 行添加到我的~/.bashrc 和~/.profile 文件中,但没有效果。 which python 仍然返回 /usr/bin/python。
然后我检查了我的别名文件以查看 python 是否别名为 Python 2。但别名文件中没有关于 python 的条目。
供您参考
- 我的
~/.bashrc看起来像这样:
$ cat ~/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
alias julia="/home/julia-1.4.0/bin/julia"
export PATH=$PATH:/home/miniconda3/envs/myenv/bin
$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
$ cat ~/.profile
export PATH=$PATH:/home/miniconda3/envs/myenv/bin
【问题讨论】:
-
which python3的输出是什么? -
@jared_mamrot
/usr/bin/python3,这不是我需要的 -
是的 - 这表明你的 python 的 conda 版本需要移动到你的路径的前面,正如@donald_stierman 所说
-
首先,我将行 export PATH=$PATH:/home/qingyanz/miniconda3/envs/myenv/bin 添加到我的 ~/.bashrc 和 ~/.profile 文件中,以 no效果。 IIRC Conda 文档建议您不要手动将其添加到 PATH 中。您是否执行了 Miniconda 的标准/正常安装?