Select to view content in your preferred language

Functions arcpy don't retrieve data

653
3
06-02-2020 05:02 AM
VsevU
by
Emerging Contributor

Hi

I try to run python script with these functions:

arcpy.ListTables()

, arcpy.ListFeatureClasses()

or

,arcpy.ListWorkspaces("*", "FileGDB")

but all the functions return right results on one computer and return "None"  on another.

Folder with GDB files was copied to both of these computers and has access by ArcCatalog correctly from the both computers.

What might be the problem? May be any security?

0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

The original ArcPy listing functions (ListTables, ListFeatureClasses, etc...) all depend on having the arcpy.env.workspace set.  Make sure the workspace is set to the same location on each machine, or the location it needs to be to see what you have copied over.

0 Kudos
VsevU
by
Emerging Contributor

Yes, of course the arcpy.env.workspace the same. But the problem solved.The path "d:\geodb\any.gdb" was specified in the configuration file. This representation of the path is correct for arcpy for the first computer, but invalid for the second computer. The path was rewritten in the following form "d:/geodb\\any.gdb" (backslash and two slashes) for the second computer. The both computers have the same OS version (windows 10). I don't know what settings do this depend on.

0 Kudos
DanPatterson
MVP Esteemed Contributor

You might want to use some of several options to validate/normalize path names, for instance

import os

pth = "d:/geodb\\any.gdb"

os.path.normpath(pth)

'd:\\geodb\\any.gdb'

... sort of retired...