在Mac上安装Anaconda的推荐方法是什么?
我尝试使用brew cask install anaconda
命令进行安装,
安装一段时间后返回anaconda已成功安装!
。
但此后,尝试使用conda
命令返回command not found: conda
。
是否需要完成其他安装步骤?
并且,在MacOS上安装Conda的推荐方式是什么?
在Mac上安装Anaconda的推荐方法是什么?
我尝试使用brew cask install anaconda
命令进行安装,
安装一段时间后返回anaconda已成功安装!
。
但此后,尝试使用conda
命令返回command not found: conda
。
是否需要完成其他安装步骤?
并且,在MacOS上安装Conda的推荐方式是什么?
安装anaconda
将路径"/usr/local/anaconda3/bin"添加到系统环境变量中
conda init <SHELL NAME>
而不是像你建议的那样直接将其添加到路径中吗?conda init 似乎除了路径之外还会添加其他内容... - Charlie Parkerbrew install --cask anaconda
。 - cormacncheeseexport PATH="/opt/homebrew/anaconda3/bin:$PATH"
,请将此命令添加到终端中,以在 Anaconda 中使用 Homebrew 的路径。 - neoswfbrew cask
不再是 brew
命令。我只使用了 brew install anaconda
。 - YouQamPATH
选项)。〜/ opt
中。 我不知道为什么会这样。 你有没有遇到过这个问题? - Charlie Parker以下是我只使用终端和苹果默认的zsh完成的方法:
# - install python
# install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# install wget to get miniconda
brew install wget
# get miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
# source /Users/my_username/opt/anaconda3/bin/activate
source ~/miniconda/bin/activate
conda init zsh
conda update -n base -c defaults conda
conda install conda-build
conda create -n iit_synthesis python=3.9
conda activate iit_synthesis
#conda remove --name metalearning2 --all
受启发于:如何在Homebrew Python系统中使用Conda?
我不知道其他人是否有过下载conda/miniconda等软件的问题,但我最近几个小时一直在尝试下载。某种原因导致使用图形界面安装程序(即.dmg
文件)时它决定安装到〜/opt
。我按照此处提供的方式卸载了如何从macOS完全卸载Anaconda并输入了rm -rf ~/opt
命令。没有这个命令好像就不能真正卸载(在重新安装之前,您可能还需要更改路径或.bash_profile
或.bashrc
,使其路径变为原始状态)。看起来使用命令行安装程序是可行的:
Anaconda3 will now be installed into this location:
/Users/brandBrandoParetoopareto/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/Users/brandBrandoParetoopareto/anaconda3] >>>
PREFIX=/Users/brandBrandoParetoopareto/anaconda3
Unpacking payload ...
Collecting package metadata (current_repodata.json): done
Solving environment: done
所以要从官方链接下载它,然后执行以下操作:
sh Anaconda3-2020.02-MacOSX-x86_64.sh
我认为使用 sh
是正确的选择,因为过去我使用 bash
的时候可能会出现问题……另外,如果你正在使用其他不同的shell,比如zsh
,我不确定你需要做什么,但我认为使用 sh
最安全。
安装完成后,您应该执行以下操作:
conda init <SHELL-NAME>
我希望conda可以正确初始化(目前似乎只修改了我的.bash_profile
和PATH
变量)。不幸的是,先前的卸载尝试并没有从我的.bash_profile
中删除先前conda init添加的代码,所以我使用vim手动删除了它。
这就是我执行该操作后得到的结果:
conda init bash
no change /Users/brandBrandoParetoopareto/anaconda3/condabin/conda
no change /Users/brandBrandoParetoopareto/anaconda3/bin/conda
no change /Users/brandBrandoParetoopareto/anaconda3/bin/conda-env
no change /Users/brandBrandoParetoopareto/anaconda3/bin/activate
no change /Users/brandBrandoParetoopareto/anaconda3/bin/deactivate
no change /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.sh
no change /Users/brandBrandoParetoopareto/anaconda3/etc/fish/conf.d/conda.fish
no change /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/Conda.psm1
no change /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/conda-hook.ps1
no change /Users/brandBrandoParetoopareto/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.csh
modified /Users/brandBrandoParetoopareto/.bash_profile
==> For changes to take effect, close and re-open your current shell. <==
bash
似乎不会重新运行您的 .bash_profile
,因此请确保您执行“关闭终端并完全重新打开它”的操作。确保conda init
正确修改了您的.bash_profile
。对于我来说,由于某种原因它在运行我的.bashrc
之后添加了它的东西,因此当我的.bashrc
尝试激活我的环境时,它不会这样做,因为它会说conda没有正确初始化(无论我重复多少次运行conda init <SHELL>
都无法解决问题)。我不知道为什么会发生这种情况,但就是这样。
我避免使用dmg/图形安装程序,因为它似乎将其安装在非标准位置~/opt
如果conda仍然表现出奇怪的行为,可能是因为您的.bashrc
修改了PATH
环境变量的方式。对我有用的是在.bashrc
中删除修改路径的行(并且在运行我的.bashrc
之前加上conda init添加的代码)。
灵感来源:
使用图形安装后,所有内容都位于~/opt目录中,正如一些先前的答案所提到的。如果这对您来说没问题,那么您只需要将~/opt/anaconda3/bin
添加到您的路径中即可使用命令行conda。这可以通过添加以下内容来实现
export PATH="${PATH}:~/opt/anaconda3/bin"
在你的rc文件末尾(~/.zshrc
或~/.bashrc
)。
$ brew install -cask anaconda
$ cat ~/.conda/requirements.txt
/example/directory/anaconda3
$ export PATH="/example/directory/anaconda3/bin:$PATH"
$ conda --help
usage: conda [-h] [--no-plugins] [-V] COMMAND ...
conda is a tool for managing and deploying applications, environments and packages.
options:
-h, --help Show this help message and exit.
--no-plugins Disable all plugins that are not built into conda.
-V, --version Show the conda version number and exit.
.
.
conda init <SHELL NAME>
时,应该自动添加,例如conda init bash
。 - Charlie Parker