<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy.mapping.MapDocument bug in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540379#M42248</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your earlier example (yesterday) you said the following functioned:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;FYI I just tested and this works.&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

os.chdir("C:/GIS/test")
arcpy.env.workspace = "C:/GIS/Test"

mxd = arcpy.mapping.MapDocument("point_2_line.mxd")

mxd.saveACopy("ortho_test_rename/testing3.mxd")&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;So arcpy.mapping.MapDocument &lt;/SPAN&gt;&lt;STRONG&gt;does NOT&lt;/STRONG&gt;&lt;SPAN&gt; always return an error when using relative path names for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also notice that you used chdir without problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your later example (from today) fails:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

arcpy.env.workspace = r"C:\GIS"

mxd = arcpy.mapping.MapDocument(r"Test\point_2_line.mxd")

mxd.saveACopy(r"Test\testing4.mxd")&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clearly some relative paths work while those that access sub folders do not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is inconsistent. Hence why I am saying it is a &lt;/SPAN&gt;&lt;STRONG&gt;bug&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This has nothing to do with chdir for me as shown in EXAMPLE 4. chdir worked fine for yourself in yesterday's example as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think we have discussed and analyzed this sufficiently to say that &lt;/SPAN&gt;&lt;STRONG&gt;arcpy.mapping.MapDocument&lt;/STRONG&gt;&lt;SPAN&gt; behaves erratically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'd also recommend removing the trailing slashes at the end of your directory strings.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Why do you recommend removing the trailing slashes? Does it cause unexpected bahaviour?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 23:26:46 GMT</pubDate>
    <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
    <dc:date>2021-12-11T23:26:46Z</dc:date>
    <item>
      <title>arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540370#M42239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s30000000n000000" rel="nofollow" target="_blank"&gt;MapDocument Syntax&lt;/A&gt;&lt;SPAN&gt; clearly states that the first input is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"A string that includes the &lt;/SPAN&gt;&lt;STRONG&gt;full path&lt;/STRONG&gt;&lt;SPAN&gt; and file name of an existing map document (.mxd) or a string that contains the keyword CURRENT"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The bug is that arcpy.mapping.MapDocument() happily &lt;/SPAN&gt;&lt;STRONG&gt;accepts a partial/relative path&lt;/STRONG&gt;&lt;SPAN&gt; yet only provides limited functionality. The arcpy.mapping.MapDocument object will fail depending on the method called. The errors messages of the methods do not refer to the cause.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A simple example &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; arcpy.env.workspace = "c:/arcgis/"&amp;nbsp; # Using a relative path mxd = arcpy.mapping.MapDocument('maps/template.mxd')&amp;nbsp; #works mxd.save()&amp;nbsp; #fails -&amp;gt; "AttributeError: MapDocObject: Unable to save. Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document." mxd.saveACopy('template_copy.mxd')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When providing a full path to the MapDocument class no error is encountered when calling the saveACopy() method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The existing &lt;/SPAN&gt;&lt;STRONG&gt;saveACopy()&lt;/STRONG&gt;&lt;SPAN&gt; error is red herring. Upon receiving a relative path the MapDocument class should return an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 10:45:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540370#M42239</guid>
      <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
      <dc:date>2012-06-18T10:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540371#M42240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to use a full path to your MXD, ie:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

mxd = arcpy.mapping.MapDocument(r"C:\arcgis\maps\template.mxd")
mxd.save()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;workspace doesn't work in this case.&amp;nbsp; There's also an answer for this in this thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/60217-using-arcpy.env.workspace-to-open-a-MXD?p=207884&amp;amp;viewfull=1#post207884" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/60217-using-arcpy.env.workspace-to-open-a-MXD?p=207884&amp;amp;viewfull=1#post207884&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540371#M42240</guid>
      <dc:creator>ThaiTruong</dc:creator>
      <dc:date>2021-12-11T23:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540372#M42241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The point of scripting in ArcGIS is not just the automation part of complex tasks, but also to gain granular control over specific tools, inputs, and outputs. Several object creations will accept invalid parameters until a function is called that looks for a parameter in a specific format and does not find it. That's when an error is thrown. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That being said, in this instance I cannot replicate this behaviour you are seeing. I have tried in an ArcGIS session and through IDLE. I get an error at mxd object creation with an invalid MXD filename error. What Service Pack are you using?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 16:24:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540372#M42241</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-18T16:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540373#M42242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still using SP2.&amp;nbsp; I just used IDLE to test and it worked for me!&amp;nbsp; See the attached image&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]15297[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 16:44:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540373#M42242</guid>
      <dc:creator>ThaiTruong</dc:creator>
      <dc:date>2012-06-18T16:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540374#M42243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That being said, in this instance I cannot replicate this behaviour you are seeing. I have tried in an ArcGIS session and through IDLE. I get an error at mxd object creation with an invalid MXD filename error. What Service Pack are you using?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was working from windows command line (executing a python file) and using ArcGIS 10.0 SP4. I am home now (in Europe) but will try to see if results vary with the python window or IDLE on Monday.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's interesting to see both of you (mzcoyle &amp;amp; ttruong) having the expected behaviour.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 17:04:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540374#M42243</guid>
      <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
      <dc:date>2012-06-18T17:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540375#M42244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I have narrowed down cause of the failure to when the source file is in directory below the current work space.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is some code that shows the successful and failing use cases:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
''' c:/arcgis/ contents:
template.mxd
maps/template2.mxd
'''

import arcpy, os

os.chdir("c:/arcgis/")
arcpy.env.workspace = "c:/arcgis/"

# EXAMPLE 1
#use full path
mxd = arcpy.mapping.MapDocument('c:/arcgis/maps/template2.mxd')
mxd.saveACopy('template2_full_path_copy.mxd')
#SUCCESSFULL

#Need to reset env path
os.chdir("c:/arcgis/")
arcpy.env.workspace = "c:/arcgis/"

# EXAMPLE 2
#use relative path but local source
mxd = arcpy.mapping.MapDocument('template.mxd')
mxd.saveACopy('template_relative_copy.mxd')
#SUCCESSFULL

# EXAMPLE 3
# Using a relative path, not local directory source
mxd = arcpy.mapping.MapDocument('maps/template2.mxd')
mxd.saveACopy('template2_copy_fails.mxd')
#FAILS -&amp;gt; "AttributeError: MapDocObject: Unable to save. Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document."
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The bug, according to the documentation, is visible in example 2 - this should not work. The call &lt;/SPAN&gt;&lt;STRONG&gt;arcpy.mapping.MapDocument('template.mxd')&lt;/STRONG&gt;&lt;SPAN&gt; should return an error and &lt;/SPAN&gt;&lt;STRONG&gt;mxd.saveACopy('template_relative_copy.mxd')&lt;/STRONG&gt;&lt;SPAN&gt; should not work. This is inconsistent with the behaviour observed in example 3.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540375#M42244</guid>
      <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
      <dc:date>2021-12-11T23:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540376#M42245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your chdir is what is doing it. You are setting the relative path via python not the arcpy module.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd also recommend removing the trailing slashes at the end of your directory strings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FYI I just tested and this works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

os.chdir("C:/GIS/test")
arcpy.env.workspace = "C:/GIS/Test"

mxd = arcpy.mapping.MapDocument("point_2_line.mxd")

mxd.saveACopy("ortho_test_rename/testing3.mxd")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540376#M42245</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T23:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540377#M42246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Your chdir is what is doing it.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;That doesn't seem to be the case. The example below (similar to EXAMPLE 3 from my previous post) still fails.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You are setting the relative path via python not the arcpy module.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I set &lt;/SPAN&gt;&lt;STRONG&gt;both &lt;/STRONG&gt;&lt;SPAN&gt;the arcpy and python paths.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'd also recommend removing the trailing slashes at the end of your directory strings.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I will do that for the example below. Could you let me know why this is beneficial?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;FYI I just tested and this works.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes as I have shown in EXAMPLE 2 (previous post above) this works. Example 3 does not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is EXAMPLE 4 which is not using chdir.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

arcpy.env.workspace = "C:/arcgis"

mxd = arcpy.mapping.MapDocument("maps/template2.mxd")
mxd.saveACopy("maps/testing7.mxd")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The inconsistent nature of arcpy.mapping.MapDocument when using relative paths is a bug.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;arcpy.mapping.MapDocument should immediately return an error when a relative path is used.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Happy Thursday,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540377#M42246</guid>
      <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
      <dc:date>2021-12-11T23:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540378#M42247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt; &lt;STRONG&gt;arcpy.mapping.MapDocument should immediately return an error when a relative path is used.&lt;/STRONG&gt; &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For me it does. There is something off with your system variable or paths settings maybe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy


arcpy.env.workspace = r"C:\GIS"

mxd = arcpy.mapping.MapDocument(r"Test\point_2_line.mxd")

mxd.saveACopy(r"Test\testing4.mxd")
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Returns this error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;Traceback (most recent call last):
&amp;nbsp; File "C:\GIS\Python\test_mxd_relative_path.py", line 7, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"Test\point_2_line.mxd")
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__
&amp;nbsp;&amp;nbsp;&amp;nbsp; assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only way I can get the error you are seeing is using chdir.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

os.chdir("C:/GIS")
arcpy.env.workspace = r"C:\GIS"

mxd = arcpy.mapping.MapDocument(r"Test\point_2_line.mxd")

mxd.saveACopy(r"Test\testing4.mxd")
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Returns this error&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;Traceback (most recent call last):
&amp;nbsp; File "C:\GIS\Python\test_mxd_relative_path.py", line 9, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.saveACopy(r"Test\testing4.mxd")
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 181, in fn_
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn(*args, **kw)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\_mapping.py", line 668, in saveACopy
&amp;nbsp;&amp;nbsp;&amp;nbsp; self._arc_object.saveACopy(file_name)
AttributeError: MapDocObject: Unable to save.&amp;nbsp; Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540378#M42247</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T23:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540379#M42248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your earlier example (yesterday) you said the following functioned:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;FYI I just tested and this works.&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

os.chdir("C:/GIS/test")
arcpy.env.workspace = "C:/GIS/Test"

mxd = arcpy.mapping.MapDocument("point_2_line.mxd")

mxd.saveACopy("ortho_test_rename/testing3.mxd")&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;So arcpy.mapping.MapDocument &lt;/SPAN&gt;&lt;STRONG&gt;does NOT&lt;/STRONG&gt;&lt;SPAN&gt; always return an error when using relative path names for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also notice that you used chdir without problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your later example (from today) fails:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy

arcpy.env.workspace = r"C:\GIS"

mxd = arcpy.mapping.MapDocument(r"Test\point_2_line.mxd")

mxd.saveACopy(r"Test\testing4.mxd")&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clearly some relative paths work while those that access sub folders do not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is inconsistent. Hence why I am saying it is a &lt;/SPAN&gt;&lt;STRONG&gt;bug&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This has nothing to do with chdir for me as shown in EXAMPLE 4. chdir worked fine for yourself in yesterday's example as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think we have discussed and analyzed this sufficiently to say that &lt;/SPAN&gt;&lt;STRONG&gt;arcpy.mapping.MapDocument&lt;/STRONG&gt;&lt;SPAN&gt; behaves erratically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'd also recommend removing the trailing slashes at the end of your directory strings.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Why do you recommend removing the trailing slashes? Does it cause unexpected bahaviour?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540379#M42248</guid>
      <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
      <dc:date>2021-12-11T23:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540380#M42249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't understand, is is really a bug if it is documented to use "full paths" or "CURRENT"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use relative paths all the time but I'm actually providing a full path to the MapDocument function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, sys
relPath = os.path.dirname(sys.argv[0])
mxd = arcpy.mapping.MapDocument(relPath + r"\project.mxd")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540380#M42249</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T23:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mapping.MapDocument bug</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540381#M42250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When used correctly there is no problem (full path as in your example).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The bug is that there exists limited functionality when using relative paths. An error should be thrown by &lt;/SPAN&gt;&lt;STRONG&gt;arcpy.mapping.MapDocument&lt;/STRONG&gt;&lt;SPAN&gt; immediately upon receiving a relative path and not later due to operations using the map document object constructed using a relative path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cyrille&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 19:00:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocument-bug/m-p/540381#M42250</guid>
      <dc:creator>CyrilleMedard_de_Chardon</dc:creator>
      <dc:date>2012-06-28T19:00:31Z</dc:date>
    </item>
  </channel>
</rss>

