<?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 Python app based on arcpy and flask returns 87934 error when trying to set arcpy.env.workspace in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-app-based-on-arcpy-and-flask-returns-87934/m-p/1360358#M69404</link>
    <description>&lt;P&gt;Hello, I've been developing a script that processes vector and raster data based on a REST API requests.&lt;/P&gt;&lt;P&gt;The script was prepared in Pycharm and worked fine on a test virtual machine (1). I created a virtual environment clone so that it could be used on the target machine (2).&lt;/P&gt;&lt;P&gt;However, when the same app is run on a different machine (2), the script returns AttributeError: ERROR 87934 when trying to set a workspace in a hardcoded path - the very beggining of the whole code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;File "C:\=====\Documents\gisapp\main.py", line 55, in set_workspace
    arcpy.env.workspace = absolute_path
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 543, in set_
    self[env] = val
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 607, in __setitem__
    ret_ = setattr(self._gp, item, value)
AttributeError: ERROR 87934&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the function that return the error. It should handle the workspace definition with all the additional code for troubleshooting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def set_workspace(location):
        absolute_path = os.path.abspath(location)
        print('Attempting to set workspace:', absolute_path)
        if isdir(absolute_path):
            print('Setting workspace:', absolute_path)
            arcpy.env.workspace = absolute_path
            set_workspace.workspace = arcpy.env.workspace
            arcpy.env.overwriteOutput = True
        else:
            print('Invalid workspace:', absolute_path)

set_workspace(r'C:\test')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The weird part is that the very same functionality is easily achieved when trying to set the workspace on the same machine (2) and generate a gdb in the same location but outside of flask, i.e. using this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
absolute_path = r'C:\test'
arcpy.env.workspace = absolute_path
arcpy.management.CreateFileGDB(absolute_path, 'baza')
print('success!')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is even more interesting, I tried to reproduce the error on the machine I use for everyday work (3) that is different from the one the script was first prepared (1) and the machine used in production (2), and it works perfectly fine.&amp;nbsp;ArcGIS Pro 3.1 is installed on each of these machines.&lt;/P&gt;&lt;P&gt;Do you guys have any idea what might cause this issue?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Jakub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 16:33:33 GMT</pubDate>
    <dc:creator>JakubWabinski</dc:creator>
    <dc:date>2023-12-13T16:33:33Z</dc:date>
    <item>
      <title>Python app based on arcpy and flask returns 87934 error when trying to set arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/python-app-based-on-arcpy-and-flask-returns-87934/m-p/1360358#M69404</link>
      <description>&lt;P&gt;Hello, I've been developing a script that processes vector and raster data based on a REST API requests.&lt;/P&gt;&lt;P&gt;The script was prepared in Pycharm and worked fine on a test virtual machine (1). I created a virtual environment clone so that it could be used on the target machine (2).&lt;/P&gt;&lt;P&gt;However, when the same app is run on a different machine (2), the script returns AttributeError: ERROR 87934 when trying to set a workspace in a hardcoded path - the very beggining of the whole code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;File "C:\=====\Documents\gisapp\main.py", line 55, in set_workspace
    arcpy.env.workspace = absolute_path
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 543, in set_
    self[env] = val
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 607, in __setitem__
    ret_ = setattr(self._gp, item, value)
AttributeError: ERROR 87934&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the function that return the error. It should handle the workspace definition with all the additional code for troubleshooting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def set_workspace(location):
        absolute_path = os.path.abspath(location)
        print('Attempting to set workspace:', absolute_path)
        if isdir(absolute_path):
            print('Setting workspace:', absolute_path)
            arcpy.env.workspace = absolute_path
            set_workspace.workspace = arcpy.env.workspace
            arcpy.env.overwriteOutput = True
        else:
            print('Invalid workspace:', absolute_path)

set_workspace(r'C:\test')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The weird part is that the very same functionality is easily achieved when trying to set the workspace on the same machine (2) and generate a gdb in the same location but outside of flask, i.e. using this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
absolute_path = r'C:\test'
arcpy.env.workspace = absolute_path
arcpy.management.CreateFileGDB(absolute_path, 'baza')
print('success!')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is even more interesting, I tried to reproduce the error on the machine I use for everyday work (3) that is different from the one the script was first prepared (1) and the machine used in production (2), and it works perfectly fine.&amp;nbsp;ArcGIS Pro 3.1 is installed on each of these machines.&lt;/P&gt;&lt;P&gt;Do you guys have any idea what might cause this issue?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Jakub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 16:33:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-app-based-on-arcpy-and-flask-returns-87934/m-p/1360358#M69404</guid>
      <dc:creator>JakubWabinski</dc:creator>
      <dc:date>2023-12-13T16:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python app based on arcpy and flask returns 87934 error when trying to set arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/python-app-based-on-arcpy-and-flask-returns-87934/m-p/1386415#M69952</link>
      <description>&lt;P&gt;In my understanding of &lt;STRONG&gt;os.path.abs&amp;nbsp;&lt;/STRONG&gt;is the last name of the full directory/file path. In example Path = C:\Users\Admin\.app, if you are using &lt;STRONG&gt;abs&lt;/STRONG&gt; then it will show the value .app&lt;/P&gt;&lt;P&gt;arcpy.env.workspace is setting the environment in full path address. So it can not obtain from the abs. In my experience I rarely use this workspace unless I need to get list of domain or list of subtype or list of featureclass for spesific project. It better uses the full path.&lt;/P&gt;&lt;P&gt;If you aim for the geoprocessing tool or gp service function in the WAB arcgis enterprise, better to use scratchFolder and scratchGDB for the output file. Maybe that's another topic.&lt;/P&gt;&lt;P&gt;Hopefully, it helps your curiosity.&lt;/P&gt;&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2024 02:20:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-app-based-on-arcpy-and-flask-returns-87934/m-p/1386415#M69952</guid>
      <dc:creator>AlexanderDanielPratama</dc:creator>
      <dc:date>2024-02-24T02:20:57Z</dc:date>
    </item>
  </channel>
</rss>

