<?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: I'm getting an 'unexpected error' in _mapping.py, line 696 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40454#M3252</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;print layer_file&lt;/SPAN&gt;&lt;BR style="background-color: #ffffff;" /&gt;&lt;SPAN style="background-color: #ffffff;"&gt;print lyrFile&lt;/SPAN&gt;&lt;BR style="background-color: #ffffff;" /&gt;&lt;SPAN style="background-color: #ffffff;"&gt;print old_wp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;K:\&amp;nbsp;&amp;lt; folders &amp;gt;\CensusTracts1980.lyr&lt;BR /&gt;Census Tracts - 1980&lt;BR /&gt;C:\Documents and Settings\ &amp;lt; user &amp;gt;\Application Data\ESRI\ArcCatalog\SDE_Reader@5151@DPH-GIS-Central.sde&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are spaces in the folder names of the layer_file path, would that matter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for taking a look!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Feb 2018 19:46:06 GMT</pubDate>
    <dc:creator>bradenmiller</dc:creator>
    <dc:date>2018-02-22T19:46:06Z</dc:date>
    <item>
      <title>I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40450#M3248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use the&amp;nbsp;findAndReplaceWorkspacePath function and I'm getting an error in the utils.py &amp;amp; _mapping.py modules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the line from _mapping.py w the error (696)&amp;nbsp;&amp;nbsp;return convertArcObjectToPythonObject(self._arc_object.findAndReplaceWorkspacePath(*gp_fixargs((find_workspace_path, replace_workspace_path, validate), True)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using PyScripter3.2.2.0, Windows 7, ArcGIS 10.4.1.&amp;nbsp; I just tried updating to the newest version of Python and that didn't do anything; same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is very basic.&amp;nbsp; I'm a python beginner, looking to update a series of .lyr files.&amp;nbsp; I'm working off of code from someone else that initially pulled in .lyr file paths from a text file, but I scaled it back to test on a single .lyr file first.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;import sys, string, os, arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;new_wp = r"&amp;nbsp;&amp;lt; new path &amp;gt; "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;layer_file = r"&amp;nbsp;&amp;lt; file path &amp;gt; "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;lyrFile = arcpy.mapping.Layer(layer_file)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;old_wp = lyrFile.workspacePath&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;lyrFile.findAndReplaceWorkspacePath(old_wp,new_wp)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; color: #1f497d;"&gt;lyrFile.save()&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 17:49:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40450#M3248</guid>
      <dc:creator>bradenmiller</dc:creator>
      <dc:date>2018-02-22T17:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40451#M3249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Throw print statements in, it is difficult to see what the problem is unless the results up to the point of failure are known&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 18:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40451#M3249</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-02-22T18:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40452#M3250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added these lines just before the&amp;nbsp;&lt;SPAN style="color: #1f497d; background-color: #ffffff;"&gt;findAndReplaceWorkspacePath call and everything looked as expected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print layer_file&lt;BR /&gt;print lyrFile&lt;BR /&gt;print old_wp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did see this expanded error messaging though, which I had missed before.&amp;nbsp; But, it doesn't really tell me anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "&amp;nbsp;&amp;lt; file path &amp;gt;", line 19, in &amp;lt;module&amp;gt;&lt;BR /&gt; lyrFile.findAndReplaceWorkspacePath(old_wp,new_wp)&lt;BR /&gt; File "C:\Program Files\ArcGIS\Desktop10.4\ArcPy\arcpy\utils.py", line 182, in fn_&lt;BR /&gt; return fn(*args, **kw)&lt;BR /&gt; File "C:\Program Files\ArcGIS\Desktop10.4\ArcPy\arcpy\_mapping.py", line 696, in findAndReplaceWorkspacePath&lt;BR /&gt; return convertArcObjectToPythonObject(self._arc_object.findAndReplaceWorkspacePath(*gp_fixargs((find_workspace_path, replace_workspace_path, validate), True)))&lt;BR /&gt;ValueError: Layer: Unexpected error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 19:27:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40452#M3250</guid>
      <dc:creator>bradenmiller</dc:creator>
      <dc:date>2018-02-22T19:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40453#M3251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there is an error in the path(s)&lt;/P&gt;&lt;P&gt;Could you share the results of the print statement&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 19:32:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40453#M3251</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-02-22T19:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40454#M3252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;print layer_file&lt;/SPAN&gt;&lt;BR style="background-color: #ffffff;" /&gt;&lt;SPAN style="background-color: #ffffff;"&gt;print lyrFile&lt;/SPAN&gt;&lt;BR style="background-color: #ffffff;" /&gt;&lt;SPAN style="background-color: #ffffff;"&gt;print old_wp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;K:\&amp;nbsp;&amp;lt; folders &amp;gt;\CensusTracts1980.lyr&lt;BR /&gt;Census Tracts - 1980&lt;BR /&gt;C:\Documents and Settings\ &amp;lt; user &amp;gt;\Application Data\ESRI\ArcCatalog\SDE_Reader@5151@DPH-GIS-Central.sde&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are spaces in the folder names of the layer_file path, would that matter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for taking a look!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 19:46:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40454#M3252</guid>
      <dc:creator>bradenmiller</dc:creator>
      <dc:date>2018-02-22T19:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40455#M3253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;spaces and the every funky @ and - really mess things up when you don't want them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Work local... work in simple paths ... that should be your first course of debugging if you are working with anything network housed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the 'user' folder!&amp;nbsp; stay clear of working there... make a folder on the c drive specific to your gis work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can definitely be arranged even in a networked and/or teaching environment, we forbid saving work to the old Docu...blah blah folder in our teaching labs because of the problems it can cause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 19:50:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40455#M3253</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-02-22T19:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: I'm getting an 'unexpected error' in _mapping.py, line 696</title>
      <link>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40456#M3254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds good, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Feb 2018 22:00:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-m-getting-an-unexpected-error-in-mapping-py-line/m-p/40456#M3254</guid>
      <dc:creator>bradenmiller</dc:creator>
      <dc:date>2018-02-22T22:00:45Z</dc:date>
    </item>
  </channel>
</rss>

