wiki:ChimeraSpyder

Developing Chimera with spyder (a python IDE)

And now for something completely different! How about installing a spyder. First, we need to install some spyder dependencies, including sip and PyQt.

WARNING: This example is an unstable solution that may not work on other platforms. This example is based on an Ubuntu linux system that had packages installed for Qt4, !PyQt4, and QScintilla2, which are spyder dependencies. Your system may need these installed, along with their development headers. Although those packages were installed on the system, they were not directly accessible to the Chimera python build. In my case, a solution was to download and build !PyQt4 within the Chimera virtual environment. The order of the following installs is important (they are successive dependency resolutions).

source ~/src/chimera-virtualenv/bin/activate
## Use debian source packages instead of direct download
#curl -O http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.5.tar.gz
#tar zxvf sip-4.10.5.tar.gz
#cd sip-4.10.5
mkdir -p ~/Downloads/deb-src
cd ~/Downloads/deb-src
apt-get source --download-only python-sip
dpkg-source -x sip4-qt3_4.10.1-0ubuntu1.dsc 
cd sip4-qt3-4.10.1/
python configure.py --help
python configure.py --debug --platform=linux-g++-64
make
make install 
deactivate
source ~/src/chimera-virtualenv/bin/activate
## Use debian source packages instead of direct download
#cd ~/Downloads
#curl -O http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-x11-gpl-4.7.4.tar.gz
#tar zxvf PyQt-x11-gpl-4.7.4.tar.gz
#cd PyQt-x11-gpl-4.7.4
mkdir -p ~/Downloads/deb-src
cd ~/Downloads/deb-src
apt-get source --download-only python-qt4-dev
dpkg-source -x python-qt4_4.7.2-0ubuntu1.dsc 
cd python-qt4-4.7.2/
# configure without installing designer plugin or QScintilla API, as these
# should be installed already by a prior installation of Qt4 or PyQt into the
# system paths
python configure.py --debug --trace --qmake=/usr/bin/qmake-qt4 --no-qsci-api --no-designer-plugin
make
make install
deactivate
source ~/src/chimera-virtualenv/bin/activate
## Use debian source packages instead of direct download
#cd ~/Downloads
#curl -O http://212.219.56.133/sites/www.ibiblio.org/gentoo/distfiles/QScintilla-gpl-2.4.3.tar.gz
#tar zxvf QScintilla-gpl-2.4.3.tar.gz
#cd QScintilla-gpl-2.4.3/Python
mkdir -p ~/Downloads/deb-src
cd ~/Downloads/deb-src
apt-get source --download-only libqscintilla2-dev
dpkg-source -x qscintilla2_2.4.3-0ubuntu1.dsc 
cd qscintilla2-2.4.3/Python
python configure.py --debug --trace
make
make install
# Ignore the failure for: cp -f QScintilla2.api /usr/share/qt4/qsci/api/python/QScintilla2.api
# The QScintilla2.api file was installed by an Ubuntu package (don't overwrite it).
# This was the last step in the install, everything else installed OK.
deactivate

Let's check the additional module dependencies for spyder. The Chimera python installation includes modules for numpy and matplotlib. The install for pylint is easy, but scipy installation is not.

source ~/src/chimera-virtualenv/bin/activate
pip install pylint
pip install pyflakes
pip install rope
deactivate

That should satisfy most of the spyder dependencies. Now try to install spyder using pip.

source ~/src/chimera-virtualenv/bin/activate
pip install spyder
deactivate

OK, if that works, then try to setup the environment and run spyder.

source ~/src/chimera-virtualenv/bin/activate
#export CHIMERA=$(cd $HOME/src/Chimera64-daily && pwd -P)
export CHIMERA=$(cd $HOME/src/Chimera64-build && pwd -P)

# PROBLEM: without LD_LIBRARY_PATH, Chimera python2.7 cannot load _md5 module,
# but with LD_LIBRARY_PATH set the spyder will segfault (probably a
# conflict with the Chimera foreign build of some library).
export LD_LIBRARY_PATH=$CHIMERA/lib
#export LD_PRELOAD=libotf.so

export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
export TCLLIBPATH="{$CHIMERA/lib}"
unset TK_LIBRARY
unset TIX_LIBRARY
export PATH=$PATH:$CHIMERA/bin
unset PYTHONHOME
unset PYTHONPATH 
spyder

If that fails (as it did for me), try using sudo privileges (this worked for me):

sudo -i
source /home/dweber/src/chimera-virtualenv/bin/activate
export CHIMERA=$(cd /home/dweber/src/Chimera64-build && pwd -P)
#export CHIMERA=/opt/UCSF/Chimera64-2010-08-24
export PATH=$PATH:$CHIMERA/bin/ 
export LD_LIBRARY_PATH=$CHIMERA/lib
export LD_PRELOAD=libotf.so
export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
export TCLLIBPATH="{$CHIMERA/lib}"
unset TK_LIBRARY
unset TIX_LIBRARY
unset PYTHONHOME
unset PYTHONPATH 
spyder

TODO: launching spyder within Chimera

Eric and I tried a few things, including launching Chimera from within spyder and also launching spyder from within Chimera-IDLE using. For the latter option, we tried:

>>> import sys
>>> sys.path.append('/home/dweber/src/chimera-virtualenv/lib/python2.7/site-packages/')
>>> from spyderlib import spyder
>>> spyder.main()

Then within the spyder we tried:

>>> import sys
>>> import os
>>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'share'))
>>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'lib'))
>>> sys.path
>>> import chimera
>>> chimera.runCommand('open 1gcn')

This command appeared to run and provide status in the Chimera main window, but the display did not update to show the molecule. So, we ran into issues with process communication or something.

A possible solution may be to clone the IDLE extension from $CHIMERA/share/Idle, to replace Idle with spyder. Looking at the Chimera-IDLE extension, we may need to hook some kind of spyder-shell into the chimera.replyobj. The spyder does have a startup option for --light, which seems to provide a basic shell-like interface. Of course, that may be no better than IDLE, so that could be pointless. The goal is to get up all the IDE features of spyder.

Last modified 16 years ago Last modified on Sep 2, 2010, 9:16:20 PM
Note: See TracWiki for help on using the wiki.