1

I'm new to ArcPy and Python and have a very simple question. I'm trying to write a Python script in idle to extract the number of feature class files from a geodatabase. I can do it just fine in the console, but when I try to write a script, I get the following error:

Traceback (most recent call last):
  File "C:\Users\ihb\Documents\assignmente_7.py", line 22, in <module>
    for feature in fcList:
TypeError: 'NoneType' object is not iterable

Here is the code that is generating the error:

#Import arcpy and set output environments
import arcpy, sys
from arcpy import env
print "Please enter desired workspace in the 'Args' space: "
if sys.modules['idlelib']: sys.argv.extend(raw_input("Args: ").split())
workSpace = sys.argv[1]
env.workspace = workSpace
env.overwriteOutput = True

#Get Feature Classes
fcList = arcpy.ListFeatureClasses()
for feature in fcList: ### <-- **ERROR OCCURS HERE** <--####
    desc = arcpy.Describe(feature)
    print feature

I need to include the sys argument so that users can specify the workspace directory.

4
  • 3
    It doesn't appear that your problem is GIS-related. You should be checking that the sys.argv[1] value is valid before using it to set the workspace.
    – Vince
    Commented Oct 11, 2019 at 16:52
  • Thank you very much!
    – ihb
    Commented Oct 11, 2019 at 21:32
  • 1
    Did @Vince solve your issue?
    – Aaron
    Commented Oct 12, 2019 at 2:47
  • @Aaron yes he did, thank you! I was putting my workspace directory in quotation marks, and I just found out you don't do that sys.argv
    – ihb
    Commented Oct 14, 2019 at 1:14

1 Answer 1

1

It turns out that I was using quotation marks to specify my workspace directory. That was my issue. You can't do that with sys.argv, apparently. I'm new to Python, so I'm learning as I go!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.