jbcbirder

Error when importing python script (IndexError: list index out of range)

Discussion created by jbcbirder on Aug 29, 2012
Latest reply on Aug 29, 2012 by mahunter243
Hi,

     I'm converting some of my pre-existing python scripts (that worked in version 9.3.1) to work with version 10 (and python 2.6). I have a script that has 3 arguments and a function. It works fine in 9.3.1 but in 10.0 (python 2.6) it is giving me an error when I simply try to import the script ...

>>> from ExportIndividualFeatures2_v10 import ExpIndFeatures
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "ExportIndividualFeatures2_v10.py", line 23, in <module>
    inWorkspace = sys.argv[1]
IndexError: list index out of range

Again, this error occurs when trying to simply import the script at the command line in PythonWin (see the command issued after the ">>>" above)

The relevant parts of the script I am importing are these lines at the beginning ...

import sys, string, os, arcpy

inWorkspace = sys.argv[1]
inShapeFile = sys.argv[2]
inField = sys.argv[3]

def ExpIndFeatures(inWorkspace, inShapeFile, inField):
    try:
        etc. etc. (code in here)


Why does this work with 9.3.1 (python 2.52 pywin 32 build 210) and not with 10.0 (python 2.6 pywin 32 build 212) ???

Outcomes