next up previous contents index
Next: Python modules within VMD Up: Python Text Interface Previous: Python Text Interface   Contents   Index

Using the Python interpreter within VMD

When you start VMD, the VMD text console normally uses the Tcl command interpreter to process what you type. In order to use the Python interpreter, you have to tell VMD to switch to 'Python mode'. There are three ways to do this: (1) Type gopython in the console window; (2) pass -python as a command line option; or (3) put gopython on the last line of your .vmdrc file. If VMD prints an error message reporting that the Python interpreter is not available, your version of VMD was not compiled with Python support; contact the VMD developers for help. If all goes well, you should see Python command prompt '$ >>>$ ' in the console window. To switch back to the Tcl interpreter, press Ctrl-D as though you were exiting Python. Switching back and forth between Python and Tcl does not destroy any of your work; all variables and modules will still be defined until you exit VMD.

Typing 'gopython $ <$ filename$ >$ ', where $ <$ filename$ >$ is the name of a file containing Python code will cause VMD to switch to Python mode, process the file, then switch back to Tcl. In this way, you can embed Python functions inside your Tcl scripts!

You can also type 'gopython -command "your code here" to run an arbitrary line of python code.


next up previous contents index
Next: Python modules within VMD Up: Python Text Interface Previous: Python Text Interface   Contents   Index
vmd@ks.uiuc.edu