每次重新运行终端时,我都必须输入 export PATH=~/anaconda/bin:"$PATH"

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

我已经安装了 Anaconda for Mac,但我有问题:

当我输入命令

which conda
which ipython
时,我得到
conda not found
ipython not find

然后我发现这个命令

export PATH=~/anaconda/bin:"$PATH"
对我有用。它解决了上面的问题,但每次我重新运行终端时问题仍然存在,我必须重新输入。

所以我想找到一个从根本上解决问题的方法

我尝试将其添加到

~/.bashrc
~/.profile
~/.bash_profile
中,但这些对我不起作用。

shell anaconda
6个回答
21
投票

.bash_profile

中尝试一下
export PATH="$HOME/anaconda/bin:$PATH"

然后尝试启动新终端并运行:

echo $PATH

输出应以 /anaconda/bin:

开头

如果仍然不起作用...解决方法可能是在运行终端后调用 bash,即输入“bash”。这应该会导致 bash 使用 .bash_profile 启动


9
投票

我在 MacOs Catalina 10.15 上运行,这对我来说很有效: shell 是 zsh!

$ source /Users/myprofilename/anaconda3/bin/activate

然后

$ conda init zsh

新的 anaconda 文档也强调了这一点


3
投票

确保您没有使用 ZShell 或其他形式的 shell。如果是这种情况,您必须添加各自 shell 文件的路径,例如

.zshrc


2
投票
sudo xed /etc/environment

打开此存档后添加:/home/youruser/anaconda3/bin


0
投票

如果您使用 ZShell,请按照以下步骤操作:

  1. 在终端中输入 open ~/.zshrc
  2. 将以下内容添加到文件中export PATH=/opt/homebrew/bin:$PATH
  3. 保存文件,然后运行以下命令source ~/.zshrc

请注意,Apple 芯片上的自制程序路径是 /opt/homebrew/bin


0
投票

conda 路径修复

最好的解决方法是将你的 conda 底座设置为自动激活。

如果你输入“no”,当它询问你是否要在需要使用 conda 时自动初始化它时,它不会通过添加以下内容来更新你的 $SHELL 变量:

export PATH="/opt/anaconda3/bin:$PATH"

在/home/user/.bashrc中

然后做:

source ~/.bashrc

检查路径是否被导出

echo $PATH

在此之后:

conda init

永久修复:

基础环境默认激活

conda config --set auto_activate_base True

基础环境默认未激活 conda config --set auto_activate_base False

上述命令仅在先运行 conda init 时才有效

希望能解决您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.