| Version 14 (modified by , 16 years ago) ( diff ) |
|---|
Installing a Python Virtual Environment for Chimera
Get a daily build of Chimera. In the examples below, it was a linux 64-bit build from 2010-08-05. To run the installation (accept all the defaults in the prompts):
$ cd ~/Downloads/ $ chmod +x chimera-alpha-linux_x86_64.exe $ sudo chimera-alpha-linux_x86_64.exe
This installation used sudo privileges to install into the default path, /opt/UCSF/Chimera64-2010-08-05. If you don't have sudo priviledges, install to an alternative path where you have write permissions. I like to have it install symlinks into
$ ls -al /usr/local/bin/chimera* lrwxrwxrwx 2 root root 42 2010-08-24 14:45 /usr/local/bin/chimera -> /opt/UCSF/Chimera64-2010-08-05/bin/chimera lrwxrwxrwx 1 root root 42 2010-08-05 14:53 /usr/local/bin/chimera-2010-08-05 -> /opt/UCSF/Chimera64-2010-08-05/bin/chimera
In the following notes, a few environment variables are set to simplify executing the new installation programs. If your installation path is different, you will need to set the CHIMERA environment variable to your path.
$ export CHIMERA=/opt/UCSF/Chimera64-2010-08-05 $ export PATH=$PATH:$CHIMERA/bin/ $ export LD_LIBRARY_PATH=$CHIMERA/lib
Now get the setuptools package installed into the python system that was specifically built and installed for Chimera. Note the following has some version specific details that need attention for any current installation. At the time of writing, this installation used a specific daily-build of Chimera (2010-08-05) and a specific version of setuptools for the version of python that was built for Chimera (python2.7).
$ sudo -i # export CHIMERA=/opt/UCSF/Chimera64-2010-08-05 # export PATH=$PATH:$CHIMERA/bin/ # export LD_LIBRARY_PATH=$CHIMERA/lib # wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg # sh setuptools-0.6c11-py2.7.egg --prefix=$CHIMERA
If you prefer to use distribute instead of setuptools, try the following:
$ sudo -i # export CHIMERA=/opt/UCSF/Chimera64-2010-08-05 # export PATH=$PATH:$CHIMERA/bin/ # export LD_LIBRARY_PATH=$CHIMERA/lib # curl -O http://python-distribute.org/distribute_setup.py # $CHIMERA/bin/python2.7 distribute_setup.py ... Processing distribute-0.6.14-py2.7.egg creating /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg Extracting distribute-0.6.14-py2.7.egg to /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages Adding distribute 0.6.14 to easy-install.pth file Installing easy_install script to /opt/UCSF/Chimera64-2010-08-05/bin Installing easy_install-2.7 script to /opt/UCSF/Chimera64-2010-08-05/bin Installed /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg Processing dependencies for distribute==0.6.14 Finished processing dependencies for distribute==0.6.14 After install bootstrap. Creating /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info Creating /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/setuptools.pth
Now use these tools to install any python package into the Chimera specific python distribution. For example, install the virtualenv package, like so:
$ sudo -i # export CHIMERA=/opt/UCSF/Chimera64-2010-08-05 # export PATH=$PATH:$CHIMERA/bin/ # export LD_LIBRARY_PATH=$CHIMERA/lib # $CHIMERA/bin/easy_install-2.7 virtualenv Searching for virtualenv Reading http://pypi.python.org/simple/virtualenv/ Reading http://virtualenv.openplans.org Best match: virtualenv 1.4.9 Downloading http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.4.9.tar.gz#md5=c49067cab242b5ff8c7b681a5a99533a Processing virtualenv-1.4.9.tar.gz Running virtualenv-1.4.9/setup.py -q bdist_egg --dist-dir /tmp/easy_install-eNIuwN/virtualenv-1.4.9/egg-dist-tmp-blYuR8 warning: no previously-included files matching '*.*' found under directory 'docs/_templates' Adding virtualenv 1.4.9 to easy-install.pth file Installing virtualenv script to /opt/UCSF/Chimera64-2010-08-05/bin Installed /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/virtualenv-1.4.9-py2.7.egg Processing dependencies for virtualenv Finished processing dependencies for virtualenv
Now that virtualenv is installed in the Chimera python distribution, we can setup any additional custom virtual environments to add python packages into the development environment. As a regular user, the following will create a Chimera-specific development environment in ~/src/chimera-virtualenv:
$ export CHIMERA=/opt/UCSF/Chimera64-2010-08-05 $ export PATH=$PATH:$CHIMERA/bin/ $ export LD_LIBRARY_PATH=$CHIMERA/lib $ mkdir -p ~/src $ cd ~/src $ $CHIMERA/bin/virtualenv chimera-virtualenv New python executable in chimera-virtualenv/bin/python2.7 Also creating executable in chimera-virtualenv/bin/python Installing setuptools.................done. $ ls -al chimera-virtualenv/ total 20 drwxr-xr-x 5 dweber dweber 4096 2010-08-24 14:05 ./ drwxr-xr-x 45 dweber dweber 4096 2010-08-24 14:05 ../ drwxr-xr-x 2 dweber dweber 4096 2010-08-24 14:05 bin/ drwxr-xr-x 2 dweber dweber 4096 2010-08-24 14:05 include/ drwxr-xr-x 3 dweber dweber 4096 2010-08-24 14:05 lib/
Once this virtual environment is created, it can be activated and deactivated with the following commands (note how the system prompt changes to indicate that we have entered and left the virtual environment).
$ source ~/src/chimera-virtualenv/bin/activate (chimera-virtualenv)$ deactivate $
Now start the Chimera build of python and import the chimera module, like this:
$ source ~/src/chimera-virtualenv/bin/activate
(chimera-virtualenv)$ python
Python 2.7 (r27:82500, Aug 5 2010, 14:15:36)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
>>> os.getenv('CHIMERA')
'/opt/UCSF/Chimera64-2010-08-05'
>>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'share'))
>>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'lib'))
>>> import chimera
>>> chimera.version.version
'alpha version 1.5 (build 31152) 2010-08-05 19:55:24 GMT'
>>> for s in sys.path: print s
...
/home/dweber/src/chimera-virtualenv/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg
/home/dweber/src/chimera-virtualenv/lib/python2.7/site-packages/pip-0.7.2-py2.7.egg
/home/dweber/src/chimera-virtualenv/lib/python27.zip
/home/dweber/src/chimera-virtualenv/lib/python2.7
/home/dweber/src/chimera-virtualenv/lib/python2.7/plat-linux2
/home/dweber/src/chimera-virtualenv/lib/python2.7/lib-tk
/home/dweber/src/chimera-virtualenv/lib/python2.7/lib-old
/home/dweber/src/chimera-virtualenv/lib/python2.7/lib-dynload
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/plat-linux2
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/lib-tk
/home/dweber/src/chimera-virtualenv/lib/python2.7/site-packages
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/distribute-0.6.14-py2.7.egg
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/virtualenv-1.4.9-py2.7.egg
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/PIL
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info
/opt/UCSF/Chimera64-2010-08-05/share
/opt/UCSF/Chimera64-2010-08-05/lib
>>>
To add additional packages into the virtual environment, try using pip.
$ source ~/src/chimera-virtualenv/bin/activate
(chimera-virtualenv)$ pip help
Usage: pip COMMAND [OPTIONS]
Options:
--version show program's version number and exit
-h, --help Show help
-E DIR, --environment=DIR
virtualenv environment to run pip in (either give the
interpreter or the environment base directory)
-s, --enable-site-packages
Include site-packages in virtualenv if one is to be
created. Ignored if --environment is not used or the
virtualenv already exists.
-v, --verbose Give more output
-q, --quiet Give less output
--log=FILENAME Log file where a complete (maximum verbosity) record
will be kept
--proxy=PROXY Specify a proxy in the form
user:passwd@proxy.server:port. Note that the
user:password@ is optional and required only if you
are behind an authenticated proxy. If you provide
user@proxy.server:port then you will be prompted for a
password.
--timeout=SECONDS, --default-timeout=SECONDS
Set the socket timeout (default 15 seconds)
Commands available:
bundle: Create pybundles (archives containing multiple packages)
freeze: Output all currently installed packages (exact versions) to stdout
help: Show available commands
install: Install packages
search: Search PyPI
uninstall: Uninstall packages
unzip: Unzip individual packages
zip: Zip individual packages
Now for something adventurous, installing the spyder python-IDE. First, we need to install some dependencies, sip and !PyQt. (In the example below, sip and PyQt are installed with sudo privileges only because Chimera was installed with those privileges. If you install Chimera without sudo privileges, try to run make install commands instead of sudo make install.)
First, this example is based on an Ubuntu linux system that had the following packages installed:
$ dpkg -l | grep libqt4 ii libqt4-assistant 4:4.6.2-0ubuntu5 Qt 4 assistant module ii libqt4-dbus 4:4.6.2-0ubuntu5 Qt 4 D-Bus module ii libqt4-designer 4:4.6.2-0ubuntu5 Qt 4 designer module ii libqt4-dev 4:4.6.2-0ubuntu5 Qt 4 development files ii libqt4-help 4:4.6.2-0ubuntu5 Qt 4 help module ii libqt4-multimedia 4:4.6.2-0ubuntu5 Qt 4 Multimedia module ii libqt4-network 4:4.6.2-0ubuntu5 Qt 4 network module ii libqt4-opengl 4:4.6.2-0ubuntu5 Qt 4 OpenGL module ii libqt4-opengl-dev 4:4.6.2-0ubuntu5 Qt 4 OpenGL library development files ii libqt4-qt3support 4:4.6.2-0ubuntu5 Qt 3 compatibility library for Qt 4 ii libqt4-script 4:4.6.2-0ubuntu5 Qt 4 script module ii libqt4-scripttools 4:4.6.2-0ubuntu5 Qt 4 script tools module ii libqt4-sql 4:4.6.2-0ubuntu5 Qt 4 SQL module ii libqt4-sql-mysql 4:4.6.2-0ubuntu5 Qt 4 MySQL database driver ii libqt4-sql-sqlite 4:4.6.2-0ubuntu5 Qt 4 SQLite 3 database driver ii libqt4-svg 4:4.6.2-0ubuntu5 Qt 4 SVG module ii libqt4-test 4:4.6.2-0ubuntu5 Qt 4 test module ii libqt4-webkit 4:4.6.2-0ubuntu5 Qt 4 WebKit module ii libqt4-xml 4:4.6.2-0ubuntu5 Qt 4 XML module ii libqt4-xmlpatterns 4:4.6.2-0ubuntu5 Qt 4 XML patterns module $ dpkg -l | grep python-qt ii python-qt4 4.7.2-0ubuntu1 Python bindings for Qt4 ii python-qt4-dev 4.7.2-0ubuntu1 Development files for PyQt4 ii python-qt4-phonon 4.7.2-0ubuntu1 Python bindings for Phonon $ dpkg -l | grep qscintilla ii libqscintilla2-5 2.4.3-0ubuntu1 The Qt4 port of the Scintilla source code editing widget ii libqscintilla2-designer 2.4.3-0ubuntu1 Qt4 Designer plugin for QScintilla 2 ii libqscintilla2-dev 2.4.3-0ubuntu1 The Scintilla source code editing widget for Qt4, development fi ii libqscintilla2-doc 2.4.3-0ubuntu1 API documentation for QScintilla 2 ii python-qscintilla2 2.4.3-0ubuntu1 Python bindings for QScintilla 2
OK, those packages were installed on the system, but some of them were not directly accessible to the Chimera python build. In this case, a solution was to download and build PyQt4 within the virtual environment, to satisfy dependencies for spyder. (I found it difficult to get the right download version for QScintilla2 to match the libraries installed on my Ubuntu system, but google searches eventually came up with an option.)
$ source ~/src/chimera-virtualenv/bin/activate (chimera-virtualenv)$ cd ~/Downloads (chimera-virtualenv)$ wget http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.5.tar.gz (chimera-virtualenv)$ tar zxvf sip-4.10.5.tar.gz (chimera-virtualenv)$ cd sip-4.10.5 (chimera-virtualenv)$ python configure.py (chimera-virtualenv)$ make (chimera-virtualenv)$ sudo make install (chimera-virtualenv)$ cd .. (chimera-virtualenv)$ wget http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-x11-gpl-4.7.4.tar.gz (chimera-virtualenv)$ tar zxvf PyQt-x11-gpl-4.7.4.tar.gz (chimera-virtualenv)$ cd PyQt-x11-gpl-4.7.4 (chimera-virtualenv)$ python configure.py --no-designer-plugin --qmake=/usr/bin/qmake-qt4 (chimera-virtualenv)$ make (chimera-virtualenv)$ sudo make install (chimera-virtualenv)$ wget http://212.219.56.133/sites/www.ibiblio.org/gentoo/distfiles/QScintilla-gpl-2.4.3.tar.gz (chimera-virtualenv)$ tar zxvf QScintilla-gpl-2.4.3.tar.gz (chimera-virtualenv)$ cd QScintilla-gpl-2.4.3 (chimera-virtualenv)$ cd Python (chimera-virtualenv)$ python configure.py (chimera-virtualenv)$ make (chimera-virtualenv)$ sudo make install
That should satisfy the dependencies for spyder. Now try to install spyder using pip.
(chimera-virtualenv)$ pip install spyder
OK, if that works, then try to setup the environment and run spyder.
$ source ~/src/chimera-virtualenv/bin/activate
(chimera-virtualenv)$ export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
(chimera-virtualenv)$ export TCLLIBPATH="{$CHIMERA/lib}"
(chimera-virtualenv)$ unset TK_LIBRARY
(chimera-virtualenv)$ unset TIX_LIBRARY
(chimera-virtualenv)$ export LD_PRELOAD=libotf.so
(chimera-virtualenv)$ export PATH=$PATH:$CHIMERA/bin
(chimera-virtualenv)$ unset PYTHONHOME
(chimera-virtualenv)$ unset PYTHONPATH
(chimera-virtualenv)$ spyder
If that fails, try the following with sudo privileges:
sudo -i
source ~/src/chimera-virtualenv/bin/activate
export CHIMERA=/opt/UCSF/Chimera64-2010-08-05
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
![[Chimera Issue Tracking System]](/trac/chimera/chrome/site/chimera_logo.png)