Python code works in ArcGIS 10.0 but not in ArcGIS 10.2

409
3
12-31-2013 08:11 AM
ValBalent
New Contributor
I know the there is anew version of Python that is running on arcGIS 10.2 Pythin 2.7.3??

Anyways these are simple out of the box functions that work in 10.0 but now not in 10.2

Here is the code snippet, last line it erros on saying it cannot fin the resource?

Any thoughts?



# Local variables:
LIVE_CIP_Shapes = "Database Connections\Connection to bangkok as clvgis.sde\LIVE.CIP_Shapes"
IMSV7_CLV_CIPMAP = "Database Connections\Connection to HANSEN DEV as IMSV7_READ.odc\IMSV7.CLV_CIPMAP"
temp_workspace_gdb = "//naples/gis_workspace/clvgis/appdata/CIP/UpdatedCIP.gdb"

Output_Layer = "CIP_Shapes_Layer"
CIP_Shapes_Layer = "CIP_Shapes_Layer"
CIP_Shapes_Layer__2_ = "CIP_Shapes_Layer"

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(LIVE_CIP_Shapes, Output_Layer, "", "", "OBJECTID OBJECTID VISIBLE NONE;HANSEN HANSEN VISIBLE NONE;HANSEN2 HANSEN2 VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;SHAPE.AREA SHAPE.AREA VISIBLE NONE;SHAPE.LEN SHAPE.LEN VISIBLE NONE")

# Process: Add Join
arcpy.AddJoin_management(Output_Layer, "HANSEN", IMSV7_CLV_CIPMAP, "APPROJECTID", "KEEP_ALL")




ERRROR MESSAGE

ERROR 000732: Join Table: Dataset Database Connections\Connection to HANSEN DEV as IMSV7_READ.odc\IMSV7.CLV_CIPMAP does not exist or is not supported
Failed to execute (AddJoin).
Tags (2)
0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Val,

Try performing the join manually using the Add Join tool.  If the tool completes, open your Results window (Geoprocessing menu > Results) and then right-click on the result > Copy As Python Snippet.  You can then paste this into a text editor and compare this to your current script.
0 Kudos
NathanHeick
Occasional Contributor II
Hello,

This looks like the issue of not properly specifying your paths.  Windows uses backslashes and Linux uses forward slashes.  In Python, forward slashes will always work or you can use os.path.sep to get the proper separator for your operating system.  If you use one backslash, Python reads it as the start of an escape code, so you have to escape it with double backslashes.  The final alternative is to use raw strings and add a lower case r before your path like follows.  This reads the string as is, which works correctly in windows.

LIVE_CIP_Shapes = r"Database Connections\Connection to bangkok as clvgis.sde\LIVE.CIP_Shapes"
 IMSV7_CLV_CIPMAP = r"Database Connections\Connection to HANSEN DEV as IMSV7_READ.odc\IMSV7.CLV_CIPMAP"


Having run across the same issue before, I imagine you copied and pasted the path from ArcCatalog.
Here is a link from the ArcGIS help on paths.

http://resources.arcgis.com/en/help/main/10.2/index.html#//002z0000000r000000
0 Kudos
NathanHeick
Occasional Contributor II
Hi Val,

Try looking at the following URL on paths in Python.  To me, you just need to fix the first two paths.  They use single backslashes.  This looks like you converted a model to Python, but the paths look like they were copied and pasted from ArcCatalog.  When you do that, usually you get single backslashes, the way Windows specifies paths.  You can add an r before the paths, or change the backslashes to double backslashes or single forward slashes.  That will probably fix it.  I paste from ArcCatalog sometimes, and then I get errors until I fix the path strings.  Look up more information about paths in Python.  The problem is that single backslashes are treated like the beginning of an escape sequence, so you either have to use the universal "/" in Python, escape the backslashes ("\\"), or specify that the strings are raw and to read them as is (r"").

http://resources.arcgis.com/en/help/main/10.2/index.html#//002z0000000r000000
0 Kudos