Anaconda and Astroconda in the Physics Department

The obvious way to install Anaconda is to use the GUI installer. However, this requires system privileges to install, so will not work on Physics Mac systems. You should instead use the command-line installer, which is rather more difficult to find on Anaconda's web site, and use nonstandard installation settings.

For your convenience, we have made Anaconda 3, and the legacy Anaconda 2, available in the Development category of Self Service. This will use the command-line installer to set up a personal instance of Anaconda for Python 3.6 (resp, 2.7) under /Data/$LOGNAME, where $LOGNAME is your login name. For me, for example, the installation directory will be:

/Data/carter/anaconda3

A link to Anaconda Navigator will also appear in ~/Applications under your home directory.

Please note: use of Anaconda with tcsh is entirely untested; in particular, it is not known whether the installation process adapts itself to the user's shell. The best way to change your default login shell is to e-mail ITSupport at Physics to request the change be made centrally.

Astroconda 3 is also available in the Astrophysics category of Self Service: this installs Anaconda for Python 3, then layers the Space Telescope Science Institute's Astroconda suite over it, in one handy metapackage. (Those wishing to use the version for Python 2, notably for use therefrom of the all-but-unmaintained IRAF, will be assumed to know what they are doing, and to be capable of doing the layering themselves on top of the abovementioned Anaconda 2.)

INSTALLATION:

Start up Self-Service, go to the Development (resp, Astrophysics) category, and click the appropriate Install button. This is a go-for-a-teabreak process: as the files are being pulled direct from the distribution sites, installation will take maybe twenty minutes, or longer if the Net's busy.

Please note: These Policies will not be visible to systems with network-mounted home directories, as crossing the network mountpoint causes breakages in certain parts of Anaconda. This shouldn't cause problems, except for the systems in Teaching, as most non-Teaching systems now have local home directories.

If you can't see one or more entries for Anaconda in the Development category of Self-Service, please contact us for alternative ways of doing business.

Users outside Astrophysics:

Users outside Astrophysics, who do not have Applications Setup available to them, will need to take the following extra steps. Please note: these instructions pertain to Anaconda3. For the legacy Anaconda2, use anaconda2 in place of anaconda3.

  • For users of bash, edit your .bashrc to include:

    export PATH=/Data/$LOGNAME/anaconda3/bin:$PATH

  • For users of tcsh, edit your .cshrc to include:

    set path = ( /Data/$LOGNAME/anaconda3/bin $PATH )

  • In either case: now start up a fresh shell, and work in that.

USAGE:

Users outside Astrophysics

To launch Anaconda, say:

  • source activate anaconda

This assumes that you have amended your shell startup files in a previous shell session.

Astrophysics users:

Readers in Astrophysics (who have Applications Setup available to them) can instead simply say the appropriate one of:

  • Activate anaconda (Anaconda eqivalent: source activate anaconda)
  • Activate anaconda astroconda (Astroconda eqivalent: source activate anaconda astroconda)
  • Activate astroconda (short for the above)

.... which do all the steps above, without having to amend any shell startup files.

Your shell prompt should then change to tell you you're inside whatever you've activated.

End of play:

To exit, exit from the shell, or say:

  • source deactivate

.... and note that your shell prompt has been reverted.

Extending Python inside Anaconda

The above produces a perfectly standard instance of Anaconda (apart from being relocated to the /Data directory), which in particular is owned by you. The Good News is that installation commands such as (eg) pip install pyfits will install Python packages into Anaconda's internal site-packages directory without fuss, and they will then become available to you without jumping through any extra hoops.

The Bad News is that you therefore necessarily have the power to entirely trash your Anaconda setup, whether by accidentally installing the wrong package (or installing the right package the wrong way), or by coup de typo, or by Python scribbling in the wrong place at an inopportune moment. If you wind up in this unfortunate position, the best recourse will be to remove the Anaconda directory and start again from scratch .... (ahem) you did keep careful notes about which packages you installed in which order, didn't you? If not, it will be worth taking the time to investigate pip freeze before doing anything drastic.

Entries are available in the Uninstall category of Self-Service for uninstalling either version of Anaconda if necessary. Please note that these will only remove instances of Anaconda installed by Self-Service, and will not amend your shell startup files.

Please see also:

Please note: It is entirely possible to install both versions of Anaconda at the same time. However, the symbolic link in ~/Applications can only point to one version's application at a time, and you will inevitably find it points to the wrong one. So, erm, don't do that; but if you must do that, rename the symbolic link before you do the second installation.

.... and one more thing:

We're happy to add packages to the Python installations in our centrally-distributed build of MacPorts, but we need your help. If you install Python packages into Anaconda, please let us know what they are, and whether they're missing from our MacPorts build.

Categories: anaconda | python | virtual Python