using python+arcpy within Eclipse

652
3
08-19-2011 09:09 AM
RalphFinch
New Contributor III
ArcGIS 10SP2, Win7x64.

I use the Eclipse IDE for other work, and would like to use it with arcpy. But I get this error:

File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__
    assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename.


the offending code line is:
mxd = arcpy.mapping.MapDocument("DSM2_Network.mxd")

This works perfectly well within, say, IDLE.

My Python interpreter libraries are as follows:



Any ideas what I've set wrong within Eclipse?
Tags (2)
0 Kudos
3 Replies
AndrewChapkowski
Esri Regular Contributor
Does it fail if you use the full path to your arcmap document?
0 Kudos
RalphFinch
New Contributor III
Does it fail if you use the full path to your arcmap document?


Oh, that's interesting...it DOES work with the full path:
mxd = arcpy.mapping.MapDocument("D:/delta/GIS/DSM2/DSM2_Network.mxd")


But from IDLE this works:
import arcpy, os, time
from arcpy.mapping import *
workspace = "D:/delta/GIS/DSM2"
mxd = arcpy.mapping.MapDocument("DSM2_Network.mxd")

Why not from Eclipse, I wonder?
0 Kudos
AndrewChapkowski
Esri Regular Contributor
I get the error for both editors.

If you look at the MapDocument object, the path parameter states the following:

A string that includes the full path and file name of an existing map document (.mxd) or a string that contains the keyword CURRENT.

I do not believe this object honors the environmental workspace parameter, and unless run from ArcMap, the full path should always be used for the map document.

You can find more information here about MapDocument
0 Kudos