What is the best way to Install Conda on MacOS (Apple/Mac)?

不打扰是莪最后的温柔 提交于 2020-04-27 07:31:33

问题


What is the recommended approach for installing Anaconda on Mac?

I tried with brew cask install anaconda
which after a while returns anaconda was successfully installed!.

After that - trying conda command returns command not found: conda.

Is there any post step installation that needs to be done?
And what is recommended way to install Conda on MacOS?


回答1:


  • brew cask install anaconda
  • export PATH="/usr/local/anaconda3/bin:$PATH"



回答2:


I would say that the recommended way to install anaconda is to use the official anaconda installer, which can be downloaded from the link I just posted. I've done it several times, never had a problem, and it walks you through it (including an option to automatically add it to your PATH).




回答3:


I don't know about other people but I've had issue downloading conda/miniconda etc for a few hours now. For some reason it decided to install at ~/opt when using the graphical installer (i.e. the .dmg file). I've been through the uninstall here How to uninstall Anaconda completely from macOS and additionall did an rm -rf ~/opt command. Seems that without this its not actually uninstalled (you might also have to change your PATH or .bash_profile or .bashrc until your path is virigin again before you start your re-installation installation). Seems that using the command line installer is what works:


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

So for that download it from the official link then do:

sh Anaconda3-2020.02-MacOSX-x86_64.sh 

do sh I believe is the right thing because I might have had issue in the past when I did bash instead...plus if you are using a different shell like zsh I am not sure what you'd need to do, but I'd get sh would be safest.

After the installation is done you should do:

conda init <SHELL-NAME>

so that conda is initialized correctly (so far that seems to only modify my .bash_profile and my PATH variable). Unfortunately, it seems the previous uninstallation attempts didn't remove the code the previous conda init had added from my .bash_profile so I removed it manually using vim.

This is what I get after doing that:

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. <==

if you are using vs-code integrated terminal like I am you need to press the trash can button. Doing bash seems to NOT re-run your .bash_profile so make sure you do what it would consider "closing your terminal and re-opening it completely".

That should be all you need to do I believe. Perhaps you also need to make sure you have the most recent version of mac OS.


Extra tips hints

  • Make sure conda init modified your .bash_profile correctly. For me for some reason it added it's stuff AFTER it ran my .bashrc and thus when my .bashrc tried activating my environment it wouldn't do it as it would say conda wasn't initialized correctly (and thus nio matter how many times I re-ran conda init <SHELL> it wouldn't fix it. I don't know why that happened but that's how it was.

  • I avoided the dmg/graphical installation since it seemed to install it at non-standard places ~/opt

  • If conda is still acting weird it might be because of the way your .bashrc modifies the PATH env variable. What worked for me was removing lines that modified my path in .bashrc (AND having the code conda init added before my .bashrc was ran).



来源:https://stackoverflow.com/questions/49118277/what-is-the-best-way-to-install-conda-on-macos-apple-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!