Skip to content

Using Anaconda Python on macOS

Andrew Boring edited this page Mar 4, 2019 · 2 revisions

Step 1: Download Anaconda
Step 2: Install Anaconda.
Step 3: Open Terminal.app and run the following:
conda create --name aci python=3.6 anaconda
(replace 3.6 with the current version of Python, if needed)
Step 4: Switch your virtualenv to "aci":
source activate aci
Step 5: Type python -V to verify the correct version of Python, or launch a jupyter notebook with jupyter notebook

Optionally, you can add shell functions to your ~/.bash_profile. I have these two currently:

psa () {
   source activate $@
}

j () {
   jupyter notebook $@
}

The psa command is short for "python source activate". When called from bash, it will execute source activate using any additional arguments passed on the command line (using the $@ shell variable). To activate your aci environment, just type psa aci. To switch to another [previously created] Python environment, just type psa SomeOtherEnvironment. If you create additional environments for other code you're working with (recommended), you can switch between them easily.

The j function runs jupyter notebook without having to type "jupyter notebook". Additional arguments are read via the $@ shell environment variable.

If you add these to your ~/.bash_profile, be sure to source your .bash-profile (source ~/.bash_profile) or close Terminal.app and open a new Terminal.app window.

Clone this wiki locally