15

I have installed the Anaconda for Mac, but there is something wrong with me:

when I type the commandwhich conda or which ipython, I get conda not found and ipython not find

Then I find this command export PATH=~/anaconda/bin:"$PATH" works for me. It solves the problem above, but everytime I rerun the terminal the problem is still there, I have to type it again.

so I want to find a way to solve the problem fundamentally

I have tried to add it into the ~/.bashrc, ~/.profile, ~/.bash_profile, but these don't work for me.

Ghrua
  • 6,746
  • 5
  • 17
  • 25
  • did u try the source ~/.bashrc command? – herokingsley Jan 29 '16 at 03:56
  • 1
    See [How to make OS X to read .bash_profile not .profile file](http://stackoverflow.com/q/18773051) – Cristian Ciupitu Jan 29 '16 at 03:59
  • Use `PS4=':${BASH_SOURCE}:${LINENO}+' bash -l -x` to get a trace of which of your dotfiles are run in what order. Look through that trace to see where PATH is being set and re-set. – Charles Duffy Jan 29 '16 at 04:08
  • ...wouldn't be surprised at all if your code is running correctly, but something is overwriting its changes later in execution; collecting the trace, as above, will show that. – Charles Duffy Jan 29 '16 at 04:09
  • 1
    BTW, I'd argue that this question is substantially mistagged. It has nothing to do with python, or ipython, or anaconda -- you'd have the exact same behavior adding any other directory to your PATH whether or not it related to this software, and subject-matter expertise on those subjects doesn't make it at all easier for someone to answer this question. – Charles Duffy Jan 29 '16 at 04:10
  • Indeed, I'd argue that it's not specific to development tools at all, and belongs on SuperUser rather than StackOverflow (since folks can need to change PATH for all manner of non-development-related reasons). – Charles Duffy Jan 29 '16 at 04:11
  • @CharlesDuffy ok, thank you very much! I will do better next time – Ghrua Jan 29 '16 at 04:40
  • @herokingsley yes, I have tried, but it have the same problem – Ghrua Jan 29 '16 at 04:41
  • ...btw, have you had a chance to run that trace? I'm curious as to whether it's illuminating. – Charles Duffy Jan 29 '16 at 04:43
  • @Hua.L, this is a case where an off-site pastebin-type facility (ideally without ads, such as https://gist.github.com/ or http://ix.io/) is probably appropriate, if the log is too long to edit into the question. – Charles Duffy Jan 29 '16 at 05:11
  • @CharlesDuffy ...ok, I am sorry. https://gist.github.com/AGrowingTree/03127a7284977c9849ba – Ghrua Jan 29 '16 at 05:21
  • @CharlesDuffy May I have your e-mail address? this is mine: waajoenglei@gmail.com – Ghrua Jan 29 '16 at 05:26
  • From that log, everything looks fine. Did you log out and back in (to activate changes to `~/.bash_profile`), or are you only activating a terminal window? I'd also suggest checking that your shell really is bash -- if you changed to zsh, fish, or similar, that would explain it. – Charles Duffy Jan 29 '16 at 15:13
  • @CharlesDuffy yeh...the problem is that I use the zsh yesterday.... and thank you for your help! – Ghrua Jan 30 '16 at 12:38

5 Answers5

21

Try this in .bash_profile

export PATH="$HOME/anaconda/bin:$PATH"

Then try launching a new terminal and running:

echo $PATH

The output should start with /anaconda/bin:

If that still doesn't work... A work around might be to invoke bash after running terminal i.e. type "bash". Which should cause bash to launch with .bash_profile

Zv_oDD
  • 1,838
  • 1
  • 18
  • 26
9

I run on MacOs Catalina 10.15 and this did the trick for me: shell is zsh !

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

then

$ conda init zsh

the new anaconda documentation also highlights this:

Kevin Hernandez
  • 1,270
  • 2
  • 19
  • 41
Axblert
  • 556
  • 4
  • 19
3

Make sure you're not using ZShell or another form of a shell. If the case you'd have to add the path to your respective shell file, e.g .zshrc.

clemens
  • 16,716
  • 11
  • 50
  • 65
kasra
  • 31
  • 1
2
sudo xed /etc/environment

after open this archive add :/home/youruser/anaconda3/bin

0

If you're using ZShell follow the steps below:

  1. In your terminal type open ~/.zshrc
  2. Add the following to the file export PATH=/opt/homebrew/bin:$PATH
  3. Save your file and then run the following command source ~/.zshrc

Please note that the homebrew path on Apple silicon is /opt/homebrew/bin