Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script to export DDP extents to tif and when I change

arcpy.mapping.ExportToTIFF(mxd,"tests\BA\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True)


arcpy.mapping.ExportToTIFF(mxd,"tests\BA\10k\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True)

--added "10k" to the directory I get

Exporting page 1 of 760 Traceback (most recent call last): File "P:\2012\183_TownPlanning_Symbology\Working\Raster_Layer_Creation\", line 10, in arcpy.mapping.ExportToTIFF(mxd,"tests\BA\10k\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\", line 181, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\", line 1373, in ExportToTIFF layout.exportToTIFF(*args) AttributeError: DataFrameObject: Error in executing ExportToTIFF

Any ideas on why?

share|improve this question
Besides what blah238 has mentioned below, even if I have all of those in place, I have had inconsistent results when using directories starting with numbers in arcpy (sometimes its ok, sometimes its not). As a rule now, I only use directories starting with a letter (and append the date on the end). For storage purposes, I copy the files etc afterwards to the folder with the name I want. – Cindy Williams Oct 22 '12 at 5:21
I do not believe there are any limitations with folders starting with numbers. I think file geodatabase tables/feature classes and possibly shapefiles must start with a letter though. – blah238 Oct 22 '12 at 6:47
up vote 7 down vote accepted

\ is an escape character in Python.

You will need to either:

  • Escape each \ with another \
  • Put an r before the opening quote to denote it as a raw string
  • Change each \ to a /
share|improve this answer
What's confusing is that it did work without the '\\' except if a number was the first character of the directory name. – GeorgeC Oct 22 '12 at 5:49
That's probably because they weren't valid escape sequences and it was falling back to the literal interpretation. \0, \1, \2 .. \7, are octal numbers which are translated into ASCII characters, thus mangling your pathnames. More info here: – blah238 Oct 22 '12 at 6:45
Wow, / is an escape character. This explains so much in my day to day amateur programming! – Cody Brown Oct 22 '12 at 19:15
\ is an escape character, / is not. – blah238 Oct 22 '12 at 19:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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