1

Problem: I am using Mac Catalina 10.15. I know that Catalina installed Python 2.7 already and I installed Python 3.7.3. Then I also installed Anaconda which contained Conda, Python 3.7.3. Now I have 3 Pythons:

A. /usr/bin/python -> python 2.7
B. /usr/bin/python3 -> python 3.7.3
C. /Users/david/anaconda3/python.app/Contents/MacOS/python -> python 3.7.6

When I type "python3" in terminal it will run B. But I want to change "python3" command to open C.

What I tried: I found "/Users/david/.bash_profile" and added

alias python3="/Users/david/opt/anaconda3/python.app/Contents/MacOS/python"

at end of the file but "python3" still opens B. How can I open Anaconda Python by typing "python3" in the terminal?

3
  • David, have you tried $ source ~/.bash_profile? Commented Apr 9, 2020 at 13:27
  • Hello Noah, you are correct. It works. Thank you very much. End this post plz. Commented Apr 9, 2020 at 13:34
  • Read my answer if you want it to load your aliases automatically every new session :) Commented Apr 9, 2020 at 13:43

1 Answer 1

2

If you have not so already, try running:

$ source ~/.bash_profile

That will load all your settings for the current terminal session. However, this will not load automatically when you start a new terminal session. For this to happen, you first need to know what shell you are running.
Run:

$ echo $SHELL
/bin/zsh

If it returns /bin/zsh like mine does(which it should since this is MacOS Catalina), you must copy your alias to the bottom of ~/.zshrc. Then your alias will automatically be loaded when you start a new terminal session.
If for some reason echo $SHELL returns something other than /bin/zsh, run:

$ chsh -s /bin/zsh

which will change your shell to zsh. Then your alias settings in ~/.zshrc will be loaded in every new terminal session.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I don't have ~/.zshrc so I add a file under /Users/david/. It works.
No. I noticed that I am not the default shell and changed back to zsh, just one hour before I read your answer. I don't know when and how I change to that shell. But anyway I changed back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.