Differences between revisions 4 and 5
Deletions are marked like this. Additions are marked like this.
Line 52: Line 52:
 * xlrd 0.7.1
 * xlwt 0.7.2
 * pysqlite 2.6.0 ( except CentOS 32-bit )
Line 53: Line 56:

Scientific Python mode in the NMR Center

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:

  1. 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.
  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.

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 ( TkInter backend in Mac platform and wxPython backend in CentOS platforms ) (c)

  • wxPython ( 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 )

Note : The list of modules indicated by (c) are compiled modules and the rest were installed using easy_install script.


  1. 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.

DevelopersGuide/NMRCenterPython/UsersGuide (last edited 2019-07-10 09:48:37 by PaulRaines)