Importing Midas within non-Chimera python installation

Hello, As part of a larger python-based project I'm working on, I need to do automated image generation with Chimera. How can the Midas module (no need for any gui components) be imported into a non-chimera installation of python? I think this is a little more complicated than just setting the PYTHONPATH to point at the chimera files, because of the compiled shared objects. For example, my attempt at importing Midas (after adding CHIMERA/share to the PYTHON PATH) raises: /home/dbryant/CHIMERA/share/Midas/__init__.py in <module>() /home/dbryant/CHIMERA/share/chimera/__init__.py in <module>() <type 'exceptions.ImportError'>: libgfxinfo.so: cannot open shared object file: No such file or directory Currently I'm using a non-gui daily build of Chimera for 64-bit Linux and calling the chimera binary via the shell (which works), but I need to be able to pass parameters to the script being run at the command line. Thanks, Drew Bryant

On Mar 5, 2009, at 12:21 PM, Drew Bryant wrote:
Currently I'm using a non-gui daily build of Chimera for 64-bit Linux and calling the chimera binary via the shell (which works), but I need to be able to pass parameters to the script being run at the command line.
I'm hoping others will chime in with regard to the errors you got when trying to import chimera modules into a standalone Python, but specifically in regard to the above you can pass arguments to your script if you tell Chimera it's a script (rather than a session file, say) by using the --script flag. Here's the pertinent info from the Chimera documentation: --script script.py Put all unprocessed arguments into sys.argv for the script to handle. The end of arguments for Chimera can be indicated with --. For example, chimera --nogui --nostatus --script myscript.py -- -p 1jhg -r 1.8 would pass the arguments -p 1jhg -r 1.8 to the script. See the Programmer's FAQ for more details. See also the commandrunscript. --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu

On Thu, 5 Mar 2009, Drew Bryant wrote:
Hello,
As part of a larger python-based project I'm working on, I need to do automated image generation with Chimera. How can the Midas module (no need for any gui components) be imported into a non-chimera installation of python? I think this is a little more complicated than just setting the PYTHONPATH to point at the chimera files, because of the compiled shared objects. For example, my attempt at importing Midas (after adding CHIMERA/share to the PYTHON PATH) raises:
/home/dbryant/CHIMERA/share/Midas/__init__.py in <module>()
/home/dbryant/CHIMERA/share/chimera/__init__.py in <module>()
<type 'exceptions.ImportError'>: libgfxinfo.so: cannot open shared object file: No such file or directory
Currently I'm using a non-gui daily build of Chimera for 64-bit Linux and calling the chimera binary via the shell (which works), but I need to be able to pass parameters to the script being run at the command line.
Thanks, Drew Bryant
To import chimera modules into a non-chimera installation of python, you need to set the CHIMERA environment variable and then import the chimeraInit module and call chimeraInit.init([]). In your case, you shouldn't need any keyword arguments to the init function, but if you were using the GUI version, then eventloop=False would very useful. Good luck! Greg Couch UCSF Computer Graphics Lab

As Greg suggested, after setting the CHIMERA environment variable, "import chimeraInit" followed by "chimeraInit.init([])" works after I added CHIMERA/lib to LD_LIBRARY_PATH. Without setting the LD_LIBRARY_PATH, chimera.__init__.py wasn't able to find the shared object files. Now "import Midas" works in my non-chimera python installation (great!). So in conclusion, the following environment variables need to be configured (on my ubuntu system at least) where CHIMERA is the path to the chimera install: LD_LIBRARY_PATH=CHIMERA/lib PYTHONPATH=CHIMERA/share:CHIMERA/lib Thanks to Greg and Eric for getting back to me so quickly. Drew On Thu, Mar 5, 2009 at 3:10 PM, Greg Couch <gregc@cgl.ucsf.edu> wrote:
On Thu, 5 Mar 2009, Drew Bryant wrote:
Hello,
As part of a larger python-based project I'm working on, I need to do automated image generation with Chimera. How can the Midas module (no need for any gui components) be imported into a non-chimera installation of python? I think this is a little more complicated than just setting the PYTHONPATH to point at the chimera files, because of the compiled shared objects. For example, my attempt at importing Midas (after adding CHIMERA/share to the PYTHON PATH) raises:
/home/dbryant/CHIMERA/share/Midas/__init__.py in <module>()
/home/dbryant/CHIMERA/share/chimera/__init__.py in <module>()
<type 'exceptions.ImportError'>: libgfxinfo.so: cannot open shared object file: No such file or directory
Currently I'm using a non-gui daily build of Chimera for 64-bit Linux and calling the chimera binary via the shell (which works), but I need to be able to pass parameters to the script being run at the command line.
Thanks, Drew Bryant
To import chimera modules into a non-chimera installation of python, you need to set the CHIMERA environment variable and then import the chimeraInit module and call chimeraInit.init([]). In your case, you shouldn't need any keyword arguments to the init function, but if you were using the GUI version, then eventloop=False would very useful.
Good luck!
Greg Couch UCSF Computer Graphics Lab
participants (3)
-
Drew Bryant
-
Eric Pettersen
-
Greg Couch