|
Size: 7089
Comment:
|
Size: 8009
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 4: | Line 4: |
| There are currently three scientific Python installations available at the Martinos Center. The two more recent installations are the [[https://store.continuum.io/cshop/anaconda/]] and the [[http://enthought.com/products/epd.php|Enthought Python Distribution (EPD)]]. The third installation is the one included with CENTOS; users of this installation are encouraged to switch to the Anaconda based installation, as it is more actively supported and contains more up to date packages. | There are currently three scientific Python installations available at the Martinos Center. The the most recent installation is the [[https://store.continuum.io/cshop/anaconda/|Anaconda]] distribution. The [[http://enthought.com/products/epd.php|Enthought Python Distribution (EPD)]] and the legacy Python Installation are older; users of these installations are encouraged to switch to the Anaconda based installation, as it is the only one still actively supported and contains more up to date packages. |
| Line 6: | Line 6: |
| If you use Python, make sure to sign up for the [[https://mail.nmr.mgh.harvard.edu/mailman/listinfo/martinos-python|martinos-python mailing list]] to receive updates regarding the Python installation and discuss Python related issues. | If you use Python, make sure to sign up for the [[https://mail.nmr.mgh.harvard.edu/mailman/listinfo/martinos-python|martinos-python mailing list]] to receive updates regarding the Python installation and discuss Python related issues. This list is also where requests for module installation should be made. |
| Line 16: | Line 16: |
| The following neuroimaging related modules are installed: | The following neuroimaging related modules are installed in the Anaconda distribution: |
| Line 26: | Line 26: |
| * [[http://pysurfer.github.com|PySurfer]] for visualization and interaction with cortical surface representations of neuroimaging data from FreeSurfer | * [[http://pysurfer.github.com|PySurfer]] for visualization and interaction with cortical surface representations of neuroimaging data from FreeSurfer (Requires using environment '''pysurfer''' in anaconda2.7) * [[http://tensorflow.org|TensorFlow]] for machine learning (Requires using either the '''tensorflow''' or '''tensorflow-gpu''' environment in anaconda2.7) |
| Line 30: | Line 32: |
| Run '''pip list''' to see a full list of modules | |
| Line 36: | Line 38: |
| On CentOS 5/6 (64-bit) do the following to enable the EPD based Python installation | On CentOS 5/6/7 (64-bit) do the following to enable the Anaconda Python installation '''For Python 2.7:''' |
| Line 39: | Line 43: |
| setenv PATH /usr/pubsw/packages/python/anaconda/bin:${PATH} | setenv PATH /usr/pubsw/packages/python/anaconda2.7/bin:${PATH} |
| Line 41: | Line 45: |
| There are 3 sub-environments in anaconda2.7: '''pysurfer''', '''tensorflow''', and '''tensorflow-gpu''' | |
| Line 42: | Line 47: |
| Within the first 30 days you will need to get a license (free for academic use). Go to the link below and click on the Anaconda Academic License button on the top right corner. Be sure to use your .edu email address, when signing up for the license. | To use a sub-environment add to your PATH |
| Line 44: | Line 49: |
| [[https://store.continuum.io/cshop/academicanaconda]] | . setenv PATH /usr/pubsw/packages/python/anaconda2.7/envs/''environment''/bin:${PATH} |
| Line 46: | Line 51: |
| '''For Python 3.7:''' | |
| Line 47: | Line 53: |
| == EPD Based Scientific Python Installation == | {{{ setenv PATH /usr/pubsw/packages/python/anaconda3.7/bin:${PATH} }}} Only the CentOS7 install is actively maintained. Run 'conda list' to see all packages installed. Email the python mailing list if you need new packages installed. You can also use the --user option to 'pip install' to install your own modules under your ~/.local directory (beware of your home dir quota) Notes for the python maintainer (person managing anaconda, not users) on saving old environments and creating new ones are [[managing_python|here]] == EPD Based Scientific Python Installation (not-maintained) == |
| Line 56: | Line 71: |
== Legacy Scientific Python Installation == |
== Legacy Scientific Python Installation (not-maintained) == |
| Line 69: | Line 83: |
| 2. Leopard systems have a customized Python 2.5.x, which, again is a necessity for a number of modules. Again, best not to tamper with it. 3. '''Isolation:''' The latest Python ( 2.6.3 ) and its associated modules are installed in /usr/pubsw/packages which are isolated from the system python and its modules. This configuration enables NMR center users to basically access both the versions of the Python and since both exist independently, they don't mess with each other. |
1. Leopard systems have a customized Python 2.5.x, which, again is a necessity for a number of modules. Again, best not to tamper with it. 1. '''Isolation:''' The latest Python ( 2.6.3 ) and its associated modules are installed in /usr/pubsw/packages which are isolated from the system python and its modules. This configuration enables NMR center users to basically access both the versions of the Python and since both exist independently, they don't mess with each other. |
| Line 75: | Line 89: |
| By default, typing "python" to invoke the Python interpreter brings up the system Python interpreter which can be verified by looking at the version. | |
| Line 76: | Line 91: |
| By default, typing "python" to invoke the Python interpreter brings up the system Python interpreter which can be verified by looking at the version. | To enable the scientific python mode, users source the scientific python mode script in the following way : |
| Line 78: | Line 93: |
| To enable the scientific python mode, users source the scientific python mode script in the following way : | |
| Line 82: | Line 96: |
| '''Note:''' strongly recommended. this line can/should be put as an alias in one's ~/.cshrc in the following way: | '''Note:''' strongly recommended. this line can/should be put as an alias in one's ~/.cshrc in the following way: |
| Line 88: | Line 103: |
| In the scientific python mode, the prompt is preceded by the text `(scientificpython)`, which lets the user know that he/she is in the scientific python mode. The user can invoke the python interpreter by typing `python` and notice that the interpreter is now the latest Python's interpreter. Once the user deactivates the mode, the prompt is changed back to the default prompt. | In the scientific python mode, the prompt is preceded by the text `(scientificpython)`, which lets the user know that he/she is in the scientific python mode. The user can invoke the python interpreter by typing `python` and notice that the interpreter is now the latest Python's interpreter. Once the user deactivates the mode, the prompt is changed back to the default prompt. |
| Line 90: | Line 105: |
| '''Note:''' The sourcing script works under tcsh shell. Bash is currently unsupported but will be if there are enough users using bash. | '''Note:''' The sourcing script works under tcsh shell. Bash is currently unsupported but will be if there are enough users using bash. |
| Line 93: | Line 108: |
* Python 2.6.3 * Numpy 1.3.0 |
* Python 2.6.3 * Numpy 1.3.0 |
| Line 99: | Line 113: |
| * IPython 0.10 | * IPython 0.10 |
| Line 109: | Line 123: |
| * pysqlite 2.6.0 ( except CentOS 32-bit ) | * pysqlite 2.6.0 ( except CentOS 32-bit ) |
| Line 114: | Line 128: |
| '''Note :''' The list of modules indicated by (c) are compiled modules and the rest were installed using easy_install script. | '''Note :''' The list of modules indicated by (c) are compiled modules and the rest were installed using easy_install script. |
| Line 118: | Line 131: |
| Line 122: | Line 134: |
| ( For advanced users ) | |
| Line 123: | Line 136: |
| ( For advanced users ) A program called `virtualenv` is made use of to isolate the Pythons. virtualenv enables one to totally switch to a different Python with its own modules ( enabled by the switch --no-site-packages). So when the user sources the `tcsh_activate` script, what he/she is effectively doing is to prefix the system PATH, PYTHONPATH, module PATHs with the custom Python's paths and when the user `deactivate`s he/she gets back all the default paths. virtualenv takes care of this complex paths manipulation behind the scenes. It also makes the modules installation a breeze for the administrator. |
A program called `virtualenv` is made use of to isolate the Pythons. virtualenv enables one to totally switch to a different Python with its own modules ( enabled by the switch --no-site-packages). So when the user sources the `tcsh_activate` script, what he/she is effectively doing is to prefix the system PATH, PYTHONPATH, module PATHs with the custom Python's paths and when the user `deactivate`s he/she gets back all the default paths. virtualenv takes care of this complex paths manipulation behind the scenes. It also makes the modules installation a breeze for the administrator. |
Scientific Python Mode in the NMR Center
Contents
There are currently three scientific Python installations available at the Martinos Center. The the most recent installation is the Anaconda distribution. The Enthought Python Distribution (EPD) and the legacy Python Installation are older; users of these installations are encouraged to switch to the Anaconda based installation, as it is the only one still actively supported and contains more up to date packages.
If you use Python, make sure to sign up for the martinos-python mailing list to receive updates regarding the Python installation and discuss Python related issues. This list is also where requests for module installation should be made.
Resources for Learning Python
* Python Scientific Lecture Notes
* The Boston Python User Group regularly holds meetings and organizes introductory Python classes
Available Python Modules
The following neuroimaging related modules are installed in the 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)
If you know of other modules that should be made available to all users, send an e-mail to the martinos-python mailing list
Run pip list to see a full list of modules
Anaconda Based Scientific Python Installation
Getting Started
On CentOS 5/6/7 (64-bit) do the following to enable the Anaconda Python installation
For Python 2.7:
setenv PATH /usr/pubsw/packages/python/anaconda2.7/bin:${PATH}There are 3 sub-environments in anaconda2.7: pysurfer, tensorflow, and tensorflow-gpu
To use a sub-environment add to your PATH
setenv PATH /usr/pubsw/packages/python/anaconda2.7/envs/environment/bin:${PATH}
For Python 3.7:
setenv PATH /usr/pubsw/packages/python/anaconda3.7/bin:${PATH}Only the CentOS7 install is actively maintained.
Run 'conda list' to see all packages installed. Email the python mailing list if you need new packages installed. You can also use the --user option to 'pip install' to install your own modules under your ~/.local directory (beware of your home dir quota)
Notes for the python maintainer (person managing anaconda, not users) on saving old environments and creating new ones are here
EPD Based Scientific Python Installation (not-maintained)
Getting Started
On CentOS 5/6 (64-bit) do the following to enable the EPD based Python installation
setenv PATH /usr/pubsw/packages/python/epd/bin:${PATH}
Legacy Scientific Python Installation (not-maintained)
Scientific Python mode is now available in the following platform/os combinations in the NMR center
- CentOS 64-bit
- CentOS 32-bit
- MacOSX Leopard (Intel)
The "system Python" ( the Python version which already exists in the system ) is not tampered with due to the following reasons:
- In CentOS systems, the Python version is very old ( 2.3.4 ) which prevents installation of many new modules essential for scientific computing in Python. However, a number of other system modules and programs are dependent on this version and it's best not to disturb this version.
- Leopard systems have a customized Python 2.5.x, which, again is a necessity for a number of modules. Again, best not to tamper with it.
Isolation: The latest Python ( 2.6.3 ) and its associated modules are installed in /usr/pubsw/packages which are isolated from the system python and its modules. This configuration enables NMR center users to basically access both the versions of the Python and since both exist independently, they don't mess with each other.
Enabling the Scientific Python mode
By default, typing "python" to invoke the Python interpreter brings up the system Python interpreter which can be verified by looking at the version.
To enable the scientific python mode, users source the scientific python mode script in the following way :
source /usr/pubsw/packages/python/2.6/scientificpython/bin/tcsh_activate
Note: strongly recommended. this line can/should be put as an alias in one's ~/.cshrc in the following way:
alias pyactivate "source /usr/pubsw/packages/python/2.6/scientificpython/bin/tcsh_activate"
Once, this is done, the user can just type pyactivate to activate the scientific python mode and type deactivate to get back to the default ( normal system python mode )
In the scientific python mode, the prompt is preceded by the text (scientificpython), which lets the user know that he/she is in the scientific python mode. The user can invoke the python interpreter by typing python and notice that the interpreter is now the latest Python's interpreter. Once the user deactivates the mode, the prompt is changed back to the default prompt.
Note: The sourcing script works under tcsh shell. Bash is currently unsupported but will be if there are enough users using bash.
List of installed modules
- Python 2.6.3
- Numpy 1.3.0
- Scipy 0.7.1 (c)
matplotlib 0.99.1.1 ( TkInter backend in Mac platform and wxPython backend in CentOS platforms ) (c)
- wxPython 2.8.10.1 ( only on CentOS platforms ) (c)
- IPython 0.10
- NetworkX 1.0rc1
- nose 0.11.1
- Sphinx 0.6.3
- Cython 0.11.3
- pynifti 0.20090303.1 (c)
- SQLAlchemy 0.6.3
- argparse 1.1
- xlrd 0.7.1
- xlwt 0.7.2
- pysqlite 2.6.0 ( except CentOS 32-bit )
- PyXML 0.8.4 (c)
- pydicom 0.9.4-1
- nibabel 1.0.0 ( cutting edge master branch Aug 27, 2010 )
Note : The list of modules indicated by (c) are compiled modules and the rest were installed using easy_install script.
Troubleshooting
pylab doesn't start: This might be because there might be a stray .matplotlibrc file, which is already existing in your path preventing the standard backend to load. As an example, pylab can't be imported if the backend is WXAgg for Mac platforms or TkAgg for CentOS platforms. The fix is to comment out the line starting with backend in your .matplotlibrc ( usually in ~/matplotlib/matplotlibrc )
Behind the Scenes
( For advanced users )
A program called virtualenv is made use of to isolate the Pythons. virtualenv enables one to totally switch to a different Python with its own modules ( enabled by the switch --no-site-packages). So when the user sources the tcsh_activate script, what he/she is effectively doing is to prefix the system PATH, PYTHONPATH, module PATHs with the custom Python's paths and when the user deactivates he/she gets back all the default paths. virtualenv takes care of this complex paths manipulation behind the scenes. It also makes the modules installation a breeze for the administrator.
