UPDATED ANSWER
After testing this, I feel it's appropriate to offer this as a simple solution for using Mac Python as the default and only using Conda Python when desired.
You need to add/move the conda
path to the end of your PATH
environment via export
command. This should allow you to use the Mac Python as the default and only use Anaconda Python after calling source activate py36
.
export PATH="$PATH:/Users/omidb/anaconda/bin"
Path Resolution
This solution assumes you have /usr/bin/
(where Mac Python is) already in your PATH
. Resolution order should check that directory first assuming it's first in the PATH
. Also, this setup does not require symlinks in /usr/local/bin
. I am not a fan of manipulating system-level resources for solutions that can be done with user resources (directories).
Default Python Setup
After moving the Anaconda path to the end of your PATH
environment variable, you can validate that which python
references /usr/bin/python
, the location for Mac Python. You will run Mac python
by default at the command line.
Running Conda Python
As previously noted, you have to call source activate py36
when you want to use the conda
virtual environment. There is no need for adding symlinks to /usr/local/bin
as they are already available through ~/anaconda/bin/
.
Furthermore, source activate py36
(or any other Anaconda environment), it will add the appropriate environment path for Anaconda python
to the beginning of your PATH
environment variable, which (referring back to Path Resolution) would be executed when run as python
on the command line. You can validate this with which python
after running source activate py36
. conda
also stores the previous path as the environment variable CONDA_PATH_BACKUP
.
Deactivating Conda
After running source deactivate
, the original path is restored, so you will then be back to running Mac python
.