Get your anaconda ready after brew install

Get your anaconda ready after brew install

add 'conda' to the path

I’m always using the Homebrew to install developement dependencies. Recently, I need Anaconda for learning python developments. So the first step is trying to install Anaconda with homebrew via brew cask install anaconda, but get this warn information while installing:

Cask anaconda installs files under /usr/local. The presence of such files can cause warnings when running "brew doctor", which is considered to be a bug in Homebrew-Cask.

To fix this bug, you need to add the /usr/local/anaconda3/bin to the PATH environment variable. Simply run this command in the terminal:

# if you're using bash
echo 'export PATH="/usr/local/anaconda3/bin:$PATH"' >> ~/.bash_profile

# if you're using zsh
echo 'export PATH="/usr/local/anaconda3/bin:$PATH"' >> ~/.zshrc

On newer macOS such as bigSur, zsh is now the default shell application.

Then, reload system variables and initialise conda:

source ~/.bash_profile
conda init

# or... if you're using zsh
source ~/.zshrc
conda init zsh

conda init is available in conda versions 4.6.12 and later.

All done! Anaconda will configure the environment automatically for you. Example of configurations (~/.zshrc) on my Mac looks like this after execute the above command:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/usr/local/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/usr/local/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/usr/local/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/usr/local/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

The same works for miniconda. If you installed it using Homebrew with brew install --cask miniconda, you need to set source of the PATH to .zshrc, for example.

echo 'export PATH="$PATH:/opt/miniconda3/bin"' >> ~/.zshrc
source ~/.zshrc

conda init zsh

That’s it, miniconda will set coresponding configurations automatically.

Update conda

If you run conda update --all for the first time, it may warn:

Verifying transaction: - WARNING conda.core.path_actions:verify(962): Unable to create environments file. Path not writable.
  environment location: /Users/<username>/.conda/environments.txt

To fix this issue, we can change the ownership of the ~/.conda directory with:

sudo chown -R $USER ~/.conda

conda update --all

If you come across other issues, please leave your comments below…

THE END
Ads by Google

林宏

Frank Lin

Hey, there! This is Frank Lin (@flinhong), one of the 1.41 billion . This 'inDev. Journal' site holds the exploration of my quirky thoughts and random adventures through life. Hope you enjoy reading and perusing my posts.

YOU MAY ALSO LIKE

Setup an IKEv2 server with strongSwan

Tutorials

2020.01.09

Setup an IKEv2 server with strongSwan

IKEv2, or Internet Key Exchange v2, is a protocol that allows for direct IPSec tunnelling between networks. It is developed by Microsoft and Cisco (primarily) for mobile users, and introduced as an updated version of IKEv1 in 2005. The IKEv2 MOBIKE (Mobility and Multihoming) protocol allows the client to main secure connection despite network switches, such as when leaving a WiFi area for a mobile data area. IKEv2 works on most platforms, and natively supported on some platforms (OS X 10.11+, iOS 9.1+, and Windows 10) with no additional applications necessary.

Hands on IBM Cloud Functions with CLI

Tools

2020.10.20

Hands on IBM Cloud Functions with CLI

IBM Cloud CLI allows complete management of the Cloud Functions system. You can use the Cloud Functions CLI plugin-in to manage your code snippets in actions, create triggers, and rules to enable your actions to respond to events, and bundle actions into packages.

Ads by Google