2

For some reason my python script crashes ever time it reaches the following code which attempts to assign a unc path as my workspace. Can any of you please help me solve this problem? Also, I'm not getting any error code when PythonWin crashes, it just does and yes I'm running my code in PythonWin.

arcpy.env.workspace = r'\\ARSENAL.LAMB.CRAYON.NET\SHARE\LEY\CTPCW3\DATA\GIS_TOTA\Projects\TOTA\2014\Data_for_Submission\2014_MASTER_TOTA.gdb'

Currently using Arcmap 10.0 PythonWin 2.6.5 (r265:79096, Mar 19 2010, 21:48:26)

1
  • 1
    This should work as-is. Have you tried just testing it from a Python command prompt? I wonder if PythonWin itself may be at fault here. I avoid it like the plague myself. – blah238 Feb 6 '14 at 17:31
1

Seems like converting my path to a Unicode string such as the string below allows me to set my workspace.

arcpy.env.workspace = u'\\ARSENAL.LAMB.CRAYON.NET\SHARE\LEY\CTPCW3\DATA\GIS_TOTA\Projects\TOTA\2014\Data_for_Submission\2014_MASTER_TOTA.gdb'

Converting my path to a Raw string as mentioned in my original post didn't seem to work all that well.

arcpy.env.workspace = r'\\ARSENAL.LAMB.CRAYON.NET\SHARE\LEY\CTPCW3\DATA\GIS_TOTA\Projects\TOTA\2014\Data_for_Submission\2014_MASTER_TOTA.gdb'
3
  • You do not need four backslashes at the start of the string with the raw string marker. The backslashes are not considered escape characters within raw strings so just use two of them like in a normal UNC path: docs.python.org/2/reference/lexical_analysis.html – blah238 Feb 6 '14 at 17:15
  • Also you are very lucky that the unicode string works because there is ample opportunity for it to break with other paths if you do not use a raw string or escape the backslashes. – blah238 Feb 6 '14 at 17:20
  • You're right about the four backslashes, I copied the wrong code into my code block while writing this subject response. Making correction now. – lemuel Feb 6 '14 at 18:18
0

I think the problem is that the initial backslash in the start of the UNC path is interpreted as an escape character. Could try:

arcpy.env.workspace = r'\\\\ARSENAL.LAMB.CRAYON.NET\SHARE\LEY\CTPCW3\DATA\GIS_TOTA\Projects\TOTA\2014\Data_for_Submission\2014_MASTER_TOTA.gdb'

Alternatively, you could mount this UNC path to a drive letter (presuming you're in Windows), which would simplify your python syntax.

6
  • the initial backslash should not matter considering I've made the path a raw string, right? Also, I'd rather not use a drive letter because several of my colleagues have different drive letter for the same path, this would result in a broken link. – lemuel Feb 4 '14 at 16:20
  • one would think the r would cover the entirety of your path string, but I figured it was an inexpensive experiment. Just tried myself. Doesn't work, nor does switching to /. :( – Roland Feb 4 '14 at 16:25
  • doesn't seem to work w/os.chdir() either. Perhaps best to debug at that level. At least there are hard error messages. – Roland Feb 4 '14 at 16:32
  • The funny thing is that the code works some days and others it doesn't. This is really frustrating. Roland, thanks for the help. – lemuel Feb 4 '14 at 16:44
  • I'm seeing plenty of stuff just on stackoverflow that seems to indicate what we're talking about should work. I don't think it's just that your UNC mounts are fluctuating since I'm getting the same problem...curious now... – Roland Feb 4 '14 at 16:49
0

I just tested setting arcpy.env.workspace to a file geodatabase via UNC path at ArcGIS 10.0 SP5 on Windows XP SP3 and it worked fine.

There is a known issue with an update to Windows 7 that can corrupt network-based file geodatabases: NIM090672: Specific Microsoft updates may result in data corruption with file geodatabases or shapefiles created on a network share

Hopefully you have a backup.

5
  • interesting. I was testing on Arc 10.0 sp5 win7 (v 6.1 sp1). Couldn't even see files in a directory w/the os module, let alone arcpy. Maybe the issue is bigger than gdbs or corruption. – Roland Feb 4 '14 at 22:06
  • Python's native support for UNC paths is spotty, but this should not have any bearing on arcpy, which is just a wrapper over C++/COM-based technologies which most certainly do support UNC paths. – blah238 Feb 4 '14 at 22:37
  • I presumed that arcpy just leverages base python to get at the file system and so can only do as good as the underlying standard python modules. Have I got that backwards? – Roland Feb 4 '14 at 22:43
  • 1
    For I/O arcpy for the most part is just calling COM libraries so yeah I don't think the os module's UNC path limitations apply here. – blah238 Feb 4 '14 at 22:51
  • good to know! thx. – Roland Feb 4 '14 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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