Skip to main content

On OSX, why is CASA crashing with references to packages that are installed externally to CASA? - Knowledgebase / Historical Articles - ALMA Science

On OSX, why is CASA crashing with references to packages that are installed externally to CASA?

Authors list

Sometimes packages that are distributed within the CASA installation (such as IPython, numpy etc.) become confused with non-CASA installations upon starting or working in CASA. Error messages like

CASA Version 4.2.2 (r30986)
Compiled on: Thu 2014/09/04 14:47:49 UTC
Traceback (most recent call last):
File "/Applications/", line 392, in <module>
from taskinit import *
File "/Applications/", line 1, in <module>
import pCASA
File "/Applications/", line 51, in <module>
import parallel_go
File "/Applications/", line 1, in <module>
from IPython.kernel import client
File "/Library/Python/2.7/site-packages/ipython-0.13.1-py2.7.egg/IPython/kernel/", line 10, in <module>
raise ImportError(__doc__)
ImportError: IPython.kernel has been replaced by IPython.parallel.

The previous version of IPython's parallel library was located at this
location (IPython.kernel). It has been moved to the IPython.parallel
subpackage and has been refactored to use zeromq/pyzmq instead of twisted.
can appear, where you can see the last file reference is a module outside the CASA directory (on OSX, the directory). On OSX, this problem has been found to occur most commonly when a package is installed by the user with the easy_install tool. This tool automatically prepends paths to its packages to the beginning of the PYTHONPATH environment variable causing CASA to try using the external installations instead of it's own. Then if there are any version incompatibilities between the package CASA is shipped with and those installed elsewhere on a user's computer, there will likely be problems.

An internal CASA code fix for this was released in CASA 4.4.0.
If you need it, a known workaround is to modify the Python easy_install.pth file to prevent it from prepending it's directories to the PYTHONPATH variable. An example of a modified version of this file is

user@fakeMachine > pwd 

user@fakeMachine > cat easy-install.pth
#import sys; sys.__plen = len(sys.path)
#import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)

Feel free to submit questions about this workaround to the ALMA Helpdesk.