From: Michael Kreim (
Date: Wed Apr 22 2009 - 03:50:59 CDT

Dear VMD users,

I observed a strange behaviour in VMD/python using command line arguments.
My program expects two file names and one atomselection string as
parameters. Everything goes well as long as my atomselection does not
contain any spaces. This leads to an error message I don't understand.

To make it short. My script:
# vmd -dispdev text -python -e test.vmdpy -args -i input.pdb -o
output.pdb -s "all"
import sys

for i in range(len(sys.argv)):
    if sys.argv[i]=="-s":
    elif sys.argv[i]=="-i":
    elif sys.argv[i]=="-o":

print "atomselction:",atomselection
print "inputpdb: ",inputpdb
print "outputpdb: ",outputpdb
# --- EOF ---

This shows this behaviour:
$ vmd -dispdev text -python -e test.vmdpy -args -i input.pdb -o
output.pdb -s "all"
Info) VMD for LINUXAMD64, version 1.8.6 (April 6, 2007)
Info) Email questions and bug reports to
Info) Please include this reference in published work using VMD:
Info) Humphrey, W., Dalke, A. and Schulten, K., `VMD - Visual
Info) Molecular Dynamics', J. Molec. Graphics 1996, 14.1, 33-38.
Info) -------------------------------------------------------------
Info) Multithreading available, 4 CPUs detected.
Info) Free system memory: 1486MB (38%)
Info) Starting Python...
Info) Text interpreter now Python
atomselction: all
inputpdb: input.pdb
outputpdb: output.pdb

$ vmd -dispdev text -python -e test.vmdpy -args -i input.pdb -o
output.pdb -s "all and not water"
argv: Index nicht im gültigen Bereich.

I tested this also with the python 2.5.1 installation of my linux
distribution and with the python2.2 binary of VMD:
$python2.2 test.vmdpy -o out -i in -s "all but not water"
atomselction: all but not water
inputpdb: in
outputpdb: out

As you can see, if I run the program without VMD everything goes well
but VMD leads to this strange "argv: Index nicht im gültigen Bereich."

What am I doing wrong? How can I pass my atomselection strings to
VMD/python-scripts via command line?

Thanking you in anticipation.

With best regards,

Michael Kreim

Dipl.-Biol. Michael Kreim <>
Technische Universität Darmstadt,
Institut für Botanik, Schnittspahnstr.3, D-64287 Darmstadt