Launching PyMOL isn't as simple as simply including the "pymol" module
(although that could change).  However, under unix at least, you can
launch it from within a python interpreter.  Just take a look at the
"pymol.com" file, which does exactly that.

PyMOL needs a little bit more information to start (PYMOL_PATH and
LD_LIBRARY_PATH for instance), and PyMOL will steal the main thread for
the GLUT/OpenGL event loop (so you should fork off a new thread first if
you want to run something in parallel).  PyMOL will also
attempt to interpret command arguments, but you can alter sys.argv
accordingly to prevent this.

With PYMOL_PATH and LD_LIBRARY_PATH set (after sourceing pymol.csh), you
could issue:

   python $PYMOL_PATH/modules/launch_pymol.py script.py

but that is basically what pymol.com does for you anyway, so you might as
well use it instead.  "pymol script.py" is the recommended (and
robust) way to launch pymol.

Running "pymol -c script.py" is almost equivalent to "python  
script.py" for command-line only mode.

The seg-fault you're getting arises from calling an uninitialized instance
of PyMOL where none of the data structures yet exist.

Cheers,
Warren

On 3 Nov 2001, Andrey Khavryuchenko wrote:

> Hi!
> 
> I've got the following problem (it may be tied to python v2 that I'm
> using):
> 
> [akh...@netmaster molmov]$ PYMOL_PATH=~/src/pymol/modules/ 
> PYTHONPATH=/homvr/src/pymol/modules/ gdb python2
> GNU gdb 5.0
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i386-redhat-linux"...
> (no debugging symbols found)...
> (gdb) run
> Starting program: /usr/bin/python2 
> [New Thread 1024 (LWP 3246)]
> Python 2.1.1 (#1, Aug 13 2001, 19:37:40) 
> [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-96)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> from glob import glob
> >>> import thread 
> >>> import threading 
> >>> import os
> >>> import sys
> >>> import time
> >>> from pymol import cmd
> >>> cmd.hide("lines")
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1024 (LWP 3246)]
> 0x402fc2be in APIEntry () at Cmd.c:106
> 106     PRINTFD(FB_API)
> (gdb) bt
> #0  0x402fc2be in APIEntry () at Cmd.c:106
> #1  0x40301b98 in CmdShowHide (self=0x0, args=0x8113d64) at Cmd.c:2517
> #2  0x80593ed in PyEval_CallObjectWithKeywords () at eval.c:41
> #3  0x8057c75 in PyEval_EvalCode () at eval.c:41
> #4  0x80597dd in PyEval_CallObjectWithKeywords () at eval.c:41
> #5  0x8057d44 in PyEval_EvalCode () at eval.c:41
> #6  0x80550d5 in PyEval_EvalCode () at eval.c:41
> #7  0x806e031 in PyRun_FileExFlags () at eval.c:41
> #8  0x806d0fc in PyRun_InteractiveOneFlags () at eval.c:41
> #9  0x806cf5e in PyRun_InteractiveLoopFlags () at eval.c:41
> #10 0x806ce2d in PyRun_AnyFileExFlags () at eval.c:41
> #11 0x8051f30 in Py_Main () at eval.c:41
> #12 0x40084777 in __libc_start_main (main=0x80519d0 <main>, argc=1, 
>     ubp_av=0xbffff704, init=0x8050e38 <_init>, fini=0x80a48f0 <_fini>, 
>     rtld_fini=0x4000dd44 <_dl_fini>, stack_end=0xbffff6fc)
>     at ../sysdeps/generic/libc-start.c:129
> (gdb) 
> 
> Red Hat Linux 7.2
> Pmw-0.8.5-1
> Numeric-20.2.1-1
> pymol both 0.68 and CVS versions
> 
> This happens only if I try to run python script utilizing pymol directly
> from python.  Launching via 'pymol script.py' goes ok.
> 
> What I'm doing wrong?
> 
> 


Reply via email to