The recommended way to run PyMOL-Python scripts is by using PyMOL as the interpreter. This is supported by all versions of PyMOL, including the pre-compiled bundles provided by Schrödinger.
Example from a shell:
shell> pymol -cq script.py
With arguments (sys.argv becomes ["script.py", "foo", "bar"]):
shell> pymol -cq script.py -- foo bar
Example from a running PyMOL instance:
PyMOL> run script.py
For advanced users, the following PyMOL versions also allow to run PyMOL from an existing Python process:
- PyMOL 2.0 based on Anaconda (using Anaconda's python, which is included in bundles provided by Schrödinger)
- Open-Source PyMOL
- Schrödinger-provided "Mac alternative X11-only build" of the 1.8.x series
After importing the pymol module, PyMOL's event loop has to be started with a call to pymol.finish_launching() (not supported on macOS).
Usage
With PyMOL 2.1, calling any ..→