0

I downloaded Anaconda on my system (Mac OS), for now solely for the purpose of using Spyder to code in Python. I am having two issues, which are probably easy to solve for someone who is more fit with computers than me. I would be glad for help!

  1. Adding anaconda to the PATH or not, and if yes, how?

In this thread here I got help with updating Anaconda and Spyder, since executing the lines conda update anaconda and conda update spyder would result in zsh: command not found. Apparently this has to do with anaconda not being added to my PATH. In that thread I was offered a workaround without adding anaconda to my path. However I would have to run a commandline everytime before I update it.

Now, I fully admit, that I don't even know what it means to add anaconda to my path. And I don't know what are the pros and cons of adding it, or not. But I kind of would like to add it, such that I don't have to look up and run this command line every time when I update. Could someone please explain if I should add anaconda to PATH, and if so, how?

  1. Which python distribution is used by what?

I am getting very confused with python distributions on my system.

  • In the panel at the bottom of Spyder I see, that it uses Python 3.7.4..
  • In the IPython console of Spyder I see that it uses Python 3.7.0.
  • If I run python --version in a terminal I get Python 2.7.16
  • If I run python3 --version in a terminal I get Python 3.7.3

Why are all these different versions on my system? If I develop a script in Spyder, and then want to run it from the terminal, then I of course would like to run it with the same python interpreter as the one Spyder uses. How can I make sure this is the case? Do I for example run a script named script.py by python script.py, by `python3 script.py´, or by yet another command line?

I am not even sure if python or python3 calls the distributions which came with anaconda, since when I run which python or which python3 I get /usr/bin/python or user /usr/bin/python3, while anaconda is installed in Users/opt/<my_username>/anaconda3/bin.

So if someone could clear the fog here for me please as well, that would be great! : )

Thanks for help!

Britzel
  • 205
  • 3
  • 8
  • This is a lot of questions - it would be better to split them out into multiple questions. For your very first one: Don't add anaconda to the PATH manually, but use `conda init `, for you probably `conda init zsh`. If conda cannot be found, use the full path. `/Users/opt//anaconda3/bin/conda init zsh`. Afterwards restart the shell. – cel May 15 '20 at 16:26
  • @cel That worked, thanks! So what it did was making the conda command(s) known to the shell? Yes, I suppose I could have asked these questions separately. But it turned out they were related. After doing what you said, the default python version changed to the one of the anaconda installation. Anyway, thanks again! – Britzel May 15 '20 at 20:16

1 Answers1

2

A Python v (most of the time 2.x) comes with macOS and you have installed anaconda for the other one version. to check this you can first run this command:

conda env list

if you have installed python2x as a new env it will show up as:

# conda environments:
#
base                  *  /Users/your_user/Applications/anaconda3
py2                      /Users/your_user/Applications/anaconda3/envs/py2

if you only see 'base' (which is for me is anaconda3 so python 3.x) then it says that you had python2.x with your macOS ( or the reverse). Normally the below command shows your default python version:

    python --version
output (for me): Python 3.7.6

Which shows the version you have with your Anaconda. If you want to use the other one, you can either 1) change this by using my answer here: How to set the default python3 to python3.7?

2) or you can add a new "env" to your anaconda environments (if in the above you see only 'base'). The instructions are mentioned here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

Anya Samadi
  • 673
  • 1
  • 5
  • 13
  • That was very helpful, thanks! After running the command which the user cel mentioned above, my default python version changed to the one of anaconda as well, so to 3.7.6.. Now I think I see through everything! Thanks! – Britzel May 15 '20 at 20:18
  • I'm happy that was helpful. :) – Anya Samadi May 16 '20 at 17:20