I am a beginner and just starting to learn how to use Python I learned from Python Scripting for Map Automation.
My question to you is that whenever I get an error I see the word Traceback or errors in highlight red in my python window.
My question to you is do I need to have a pythonWin installed ? My computer at work does not have it but I use the python Window inside ArcMap.
Are there site that can I read or learn about the Traceback error ? I am sure there are bunch of question that Traceback has in it.
So what does Traceback means and what does it do ?
Thanks
I put that damn r into what you suggest and it worked ...
Is the "r" stand for reclusive , correct ?
Glad it worked. The r is for "Raw String Notation":
https://docs.python.org/3.3/library/re.html#raw-string-notation (sorry 3.3 docs)https://docs.python.org/3.3/library/re.html#raw-string-notation
If you copy and paste a path in python code it will probably be invalid since you have to use double backward slashed, forwards slashes or the r in front of the string holding the path. Normally the last option is the easiest,
Are you saying that when I copy and paste the code into python window in ArcMap does it give you an errors ?
So that means do I have to re-type them ?
Earlier I mention that it worked.. That was all about the file geodatabase. Now I have one shapefile in the same mxd that did not replace to the new workspace.
>>> mxd = arcpy.mapping.MapDocument("CURRENT")
>>> path = "E:\ned10DEM\Contours"
>>> mxd.replaceWorkspaces(r"\E:\FY2011_projects\10mNED\Contours","SHAPEFILE_WORKSPACE", path + r"\","SHAPEFILE_WORKSPACE")
I still got an error here : Parsing error SyntaxError: invalid syntax (line 1)
I think it should be:
mxd = arcpy.mapping.MapDocument("CURRENT") path = r"E:\ned10DEM\Contours" mxd.replaceWorkspaces(r"E:\FY2011_projects\10mNED\Contours","SHAPEFILE_WORKSPACE", path,"SHAPEFILE_WORKSPACE")
each time you specify a path (as string) place the r in front of it.
What are you using to run this code ? PyScripter ? BTW Thanks.
I didn't run the code, but when I do I use PyScripter.
Using Python Windows within ArcMap. I think I need to try and use PyScripter. I have to ask my IT Specialist for permission to use it on my computer.
Thanks.
If I'm correct you can download the ZIP which does not need an installation...
zip file for registry free installation
It installs with a different shortcut for each Python version. Do we need to make sure we are running the PyScripter for Python 2.7 so it's "compatible" with ArcGIS? I seem to remember something about this being the case.