<?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: Error setting workspace in arcpy.env in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395635#M31251</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is this being done in the Python window in ArcMap? Have you tried running it as a stand alone script?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Oct 2011 21:10:03 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2011-10-12T21:10:03Z</dc:date>
    <item>
      <title>Error setting workspace in arcpy.env</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395632#M31248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am encountering errors with setting a workspace file path in some installations of ArcGIS 10. When I run the code in a Python editor, it runs fine. When I run the code in the Python window or as a script tool, it fails on 2 out of 4 machines I have tested, resulting in the error message 00732: the dataset doesn't exist or is not supported.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the relevant section of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys, os, string, arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Define workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = "c:/WorkSpace/Exercise3"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set overwrite option&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput - True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Define the input datasets&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cities = "Larimer_Cities.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;county = "Larimer_County.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script fails when it calls for the first input dataset, which it does not find. I have tried various ways of representing the workspace filepath (/, \\, r"..), and the only successful workaround I have found is to specify the full filepath for all input and output datasets. Since this only happens on some of the ArcGIS installations I have tested, it leads me to believe that somehow the environment setting for workspace is being overridden. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sarah&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 15:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395632#M31248</guid>
      <dc:creator>SarahReed</dc:creator>
      <dc:date>2011-10-12T15:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error setting workspace in arcpy.env</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395633#M31249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I noticed you have this&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.overwriteOutput - True
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;but it should be&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.overwriteOutput = True
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition, you can try doing the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
cities = str(arcpy.env.workspace) + os.sep + "Larimer_Cities.shp"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does the data exist at the workspace path specified?&amp;nbsp; If I do for example this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
arcpy.env.workspace = r"pathto\scratch.gdb"
desc = arcpy.Describe("FeatureClassName")
print desc.name
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the feature class's name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also test your code by using the arcpy.Exists():&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.workspace = "mypath"
cities = "Larimer_Cities.shp"
print arcpy.Exists(cities)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395633#M31249</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-11T18:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error setting workspace in arcpy.env</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395634#M31250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apologies for that first mistake; it was a typo.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The data does exist within the workspace path specified. When running the script from the Python window, I am able to confirm that the workspace path is set correctly and that the feature class exists, but when I reach the first analysis that calls for the data (in this case, a buffer analysis), I stlll get the error message stating that the data does not exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The alternate syntax you suggested (specifically, converting the workspace path to a string) does work, but I am still confused about why the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00210000001m000000.htm"&gt;syntax given by ESRI&lt;/A&gt;&lt;SPAN&gt; does not work in some cases.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some way that my environment settings are being overridden, even during the execution of a script?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 20:19:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395634#M31250</guid>
      <dc:creator>SarahReed</dc:creator>
      <dc:date>2011-10-12T20:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error setting workspace in arcpy.env</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395635#M31251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is this being done in the Python window in ArcMap? Have you tried running it as a stand alone script?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 21:10:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395635#M31251</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-10-12T21:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error setting workspace in arcpy.env</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395636#M31252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, running it as a stand-alone script (from PythonWin or IDLE) works fine with the standard syntax for setting a workspace. I encounter the error only when running the script from the Python window or as a script tool in ArcToolbox.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 21:15:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395636#M31252</guid>
      <dc:creator>SarahReed</dc:creator>
      <dc:date>2011-10-12T21:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error setting workspace in arcpy.env</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395637#M31253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Open a fresh instance of ArcMap, go to Geoprocessing &amp;gt; Environments remember what it says is your current workspace. Then go to the Python window and enter &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;print arcpy.env.workspace&lt;/PRE&gt;&lt;SPAN&gt;If they don't match there is a problem somewhere deeper than simple code may be able to fix. I've seen some wonky things happen with errant registry edits moving default workspaces around.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 21:30:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-workspace-in-arcpy-env/m-p/395637#M31253</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-10-12T21:30:49Z</dc:date>
    </item>
  </channel>
</rss>

