Welcome to our Support Center
< All Topics

Using Python at the Martinos Center

Resources for Learning Python

Installing a Custom Python for Yourself with Anaconda

Follow the directions at Installing Anaconda. You can skip the Prerequisites part as it is done on all our systems.

Make sure NOT to install the distribution into your home directory as your home directory quota is too small. Various things conda/pip do will also write lots of data to your ~/.conda, ~/.cache/pip and ~/.local/share/python* directories so you may need to symlink these to group storage volumes with more space.

Also I strongly suggest NOT having your ~/.cshrc or ~/.bashrc initialize your Anaconda install immediately on login. Instead setup a shell alias to do that on demand in each shell/Terminal when you need it. Anaconda can put binaries in your PATH that can interfere with other Linux systems program or even prevent GUI login from working. NoMachine, VNC and OpenOffice are known to break when sourcing anaconda automatically depending on the packages installed in your environment.

Another option is set “auto_activate_base: false” in your ~/.condarc file.

Using venv module with OS installed python

Using the venv module with the system OS installed python is a simple and quick way to install modules with pip you need that have no complicated 3rd party dependencies. Here is an example of using this method to install jupyter:

 cd /vast/itgroup/raines
 mkdir jupyter
 python3 -m venv /vast/itgroup/raines/jupyter
 source /vast/itgroup/raines/jupyter/bin/activate
 pip3 install --upgrade pip
 pip3 install jupyterlab
 /vast/itgroup/raines/jupyter/bin/jupyter lab --no-browser 

Note that you will have to do the source line in other shells or in new logins. It is still best NOT to put this in your login scripts unless you know it will not interfere with other programs.

Neuroimaging Python Modules

The following neuroimaging related modules are ones many users will want to install in their Anaconda distribution:

  • mne-python for M/EEG analysis
  • nibabel provides access to a large number of neuro-imaging file formats
  • nitime for time-series analysis <
  • pydicom enables you to read, modify and write DICOM files with python code
  • PySurfer for visualization and interaction with cortical surface representations of neuroimaging data from FreeSurfer (Requires using environment pysurfer in anaconda2.7)
  • TensorFlow for machine learning (Requires using either the tensorflow or tensorflow-gpu environment in anaconda2.7)

Always prefer installing a module using the conda installer with a prebuilt package. If you cannot find one that then you can resort to building it with pip.

Run pip list to see a full list of modules

Anaconda is also a good way to install and run R

Table of Contents