Select to view content in your preferred language

Arcgis10: Python error : RuntimeError : method datasetType does not exist

4568
6
02-01-2011 01:47 AM
XavierMauclaire
Emerging Contributor
Hi
I develop python script with eclipse.
When i run the code under eclipse ou  with the dos command line ), i get the error "function not found"...


This code runs well under the python console of arccatalog

I set the PYTHONPATH with the arcgis 10 bin an arccpy directories .. no issue !!

Please Help !!! je craque !!!


My code :


import arcpy


if __name__ == '__main__':
    zPath = "c:/test.shp"
    print"toto"
    pDesc = arcpy.Describe(zPath)
#    error here RuntimeError: DescribeData: Method DatasetType does not exist
    print pDesc.DatasetType
   
# and here
    pExtent = pDesc.Extent
   
   
# and here
    print "Extent of shape :\nXMin: %f, YMin: %f, \nXMax: %f, YMax: %f" % \
        (pExtent.XMin,pExtent.YMin,pExtent.XMax,pExtent.YMax)

# and here
    pSr = pDesc.spatialReference
   
    print pSr.name
0 Kudos
6 Replies
by Anonymous User
Not applicable
Try setting your env.workspace

import arcpy
from arcpy import env

if __name__ == '__main__':
    env.workspace = 'c:/temp/python'

    zPath = "c:/temp/python/test.shp"
    print"toto"
    pDesc = arcpy.Describe(zPath)
    # error here RuntimeError: DescribeData: Method DatasetType does not exist
    print pDesc.DatasetType

    # and here
    pExtent = pDesc.Extent


    # and here
    print "Extent of shape :\nXMin: %f, YMin: %f, \nXMax: %f, YMax: %f" % \
    (pExtent.XMin,pExtent.YMin,pExtent.XMax,pExtent.YMax)

    # and here
    pSr = pDesc.spatialReference

    print pSr.name


You should get something like:
C:\Temp\Python>python test.py
toto
FeatureClass
Extent of shape :
XMin: 1727760.654081, YMin: 657671.252142,
XMax: 1733764.605903, YMax: 662427.894069
NAD_1983_StatePlane_Tennessee_FIPS_4100_Feet

C:\Temp\Python>
0 Kudos
by Anonymous User
Not applicable
Original User: Xavier

Yes il should sir..
I get this when i run the script from the arccatalog python console
But i get this when i use the dos command line

toto
toto
Traceback (most recent call last):
  File "C:\Users\xmauclaire\Documents\Etudes\GeoDoc_DI104\Dev\Python\pygeodoc\src\Setbounds.py", line 24, in <module>
    print pDesc.datasetType
RuntimeError: DescribeData: Method datasetType does not exist

Any idea ?
regards
0 Kudos
by Anonymous User
Not applicable
Did you add/modify what I posted?

Primarly

from arcpy import env
env.workspace = 'c:/temp/python'
zPath = "c:/temp/python/test.shp"

Set to your environment.
0 Kudos
by Anonymous User
Not applicable
Original User: Xavier

Yes sir i did that and got the same result !

On the other hand i can get defaults describe attributes (baseName, file etc) but not other specific attributes.
if with the debuger i do a  hasattr(pDesc, "datasetType"), the answer is false...
amazing isn't it ?

regards
0 Kudos
by Anonymous User
Not applicable
Then I don't know. Two things I would try:

1) Add C:\Python26\ArcGIS10.0 to your system path and execute the .PY  the way I did.

2) Put your code in a folder that does not contain spaces.  Something like C:\temp for testing.  Make it simple until you can figure out what's throwing the error.

You don't have multiple versions of Python your box do you?
0 Kudos
by Anonymous User
Not applicable
Original User: Xavier

The Path variable is ok
I'm going to test your idea.
Thanks for all.
regards
0 Kudos