-
Notifications
You must be signed in to change notification settings - Fork 98
How to solve PySurfer installation issues on Anaconda 1.8 with MacOSX 10.7.5
If you try to install PySurfer using pip you will get the following error:
pip install pysurfer
Downloading/unpacking pysurfer
Downloading pysurfer-0.4.tar.gz
Running setup.py egg_info for package pysurfer
Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/ or in the resources directory of your application bundle.
Complete output from command python setup.py egg_info:
Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/ or in the resources directory of your application bundle.
In order to solve it, download and install the master branch from github
(PySurfer-master.zip, version 0.5.dev, the pysurfer available with pip is version is 0.4).
Now that the installation issue is solved, let's try to execute PySurfer in IPython:
ipython --pylab qt
you will get the following error:
[TerminalIPythonApp] WARNING | Eventloop or matplotlib integration failed. Is matplotlib installed?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Users/user/anaconda/lib/python2.7/site-packages/IPython/core/shellapp.pyc in <lambda>(key)
221 shell = self.shell
222 if self.pylab:
--> 223 enable = lambda key: shell.enable_pylab(key, import_all=self.pylab_import_all)
224 key = self.pylab
225 elif self.matplotlib:
/Users/user/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_pylab(self, gui, import_all, welcome_message)
2924 from IPython.core.pylabtools import import_pylab
2925
-> 2926 gui, backend = self.enable_matplotlib(gui)
2927
2928 # We want to prevent the loading of pylab to pollute the user's
/Users/user/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
2885 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
2886
-> 2887 pt.activate_matplotlib(backend)
2888 pt.configure_inline_support(self, backend)
2889
/Users/user/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in activate_matplotlib(backend)
240 matplotlib.rcParams['backend'] = backend
241
--> 242 import matplotlib.pyplot
243 matplotlib.pyplot.switch_backend(backend)
244
/Users/user/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
96
97 from matplotlib.backends import pylab_setup
---> 98 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
99
100
/Users/user/anaconda/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
26 # imports. 0 means only perform absolute imports.
27 backend_mod = __import__(backend_name,
---> 28 globals(),locals(),[backend_name],0)
29
30 # Things we pull in from all backends
/Users/user/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py in <module>()
11
12 from backend_agg import FigureCanvasAgg
---> 13 from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
14 show, draw_if_interactive, backend_version, \
15 NavigationToolbar2QT
/Users/user/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_qt4.py in <module>()
23 figureoptions = None
24
---> 25 from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__
26
27 backend_version = __version__
/Users/user/anaconda/lib/python2.7/site-packages/matplotlib/backends/qt4_compat.py in <module>()
34 # Now perform the imports.
35 if QT_API in (QT_API_PYQT, QT_API_PYQTv2):
---> 36 import sip
37 if QT_API == QT_API_PYQTv2:
38 if QT_API_ENV == 'pyqt':
ImportError: No module named sip
Despite this error, ipython is still working, but if you try
from surfer import Brain
brain=Brain('fsaverage','both','inflated')
The resulting TVTK Scene will contain nothing, and it will be completely frozen.
I think this error is related with pyqt (in this case ipython is using pyqt as frontend), so in order to solve it, let's change the ipython frontend to pyside. This can be done by creating the following variable in the shell (to make it permanent, please include the following line in the .bash_profile file and source the file or "close and open the terminal"):
export QT_API=pyside
Let's verify that our solution is really working:
ipython --pylab qt
As you can see, this time everything is working fine!, including PySurfer!
from surfer import Brain
brain=Brain('fsaverage','both','inflated')
Let's verify the backend that we are using:
In [1]: matplotlib.rcParams['backend']
Out[1]: 'Qt4Agg'
In [2]: matplotlib.rcParams['backend.qt4']
Out[2]: 'PyQt4'
Using PySide as backend also works fine:
In [6]: matplotlib.rcParams['backend.qt4']='PySide'
Let's use PySurfer from the ipython notebook:
ipython notebook --pylab=qt
Everything works fine!. In case you get a frozen window when you try to interact with the TVTK scene, you can explicitly integrate the qt event loop in the ipython event loop, by explicitly adding the following magic method invocation to your notebook:
%gui qt