<?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 Can't list custom toolbox in ArcGIS Server's Python environment. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-t-list-custom-toolbox-in-arcgis-server-s/m-p/683925#M52943</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;I've developed a custom toolbox that I'd like to run from a Python script. Using the ArcGIS Pro Python environment, I can load the toolbox and execute a tool from it:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; arcpy.ImportToolbox(os.path.join(script_path, "My Toolbox.tbx"))&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; arcpy.MyTool_MyToolbox(a_workspace, b_workspace, output_workspace)
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works without a problem.&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;However, I can't guarantee that an ArcGIS Pro license will be available (the user might have signed out of arcgis.com). I&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;EM&gt;can&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;guarantee that an ArcGIS Server license will be available, so I think I should be able to run it from ArcGIS Server's Python environment.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;In Visual Studio Code, if I switch to ArcGIS Server's Python environment (C:\Python27\ArcGISx6410.8\python.exe), I get the following error when trying to execute the tool:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; 'module' object has no attribute 'MyTool_MyToolbox'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;If I call arcpy.ListToolboxes(), the&amp;nbsp;MyToolbox toolbox is one of the toolboxes returned. However, the&amp;nbsp;MyTool&amp;nbsp;tool is not returned by arcpy.ListTools().&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;I've verified that I can list the tool in ArcGIS Pro's Python environment.&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;ArcGIS Pro 2.5.1&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;ArcGIS Server 10.8&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:47:33 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-12T16:47:33Z</dc:date>
    <item>
      <title>Can't list custom toolbox in ArcGIS Server's Python environment.</title>
      <link>https://community.esri.com/t5/python-questions/can-t-list-custom-toolbox-in-arcgis-server-s/m-p/683925#M52943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;I've developed a custom toolbox that I'd like to run from a Python script. Using the ArcGIS Pro Python environment, I can load the toolbox and execute a tool from it:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; arcpy.ImportToolbox(os.path.join(script_path, "My Toolbox.tbx"))&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; arcpy.MyTool_MyToolbox(a_workspace, b_workspace, output_workspace)
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works without a problem.&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;However, I can't guarantee that an ArcGIS Pro license will be available (the user might have signed out of arcgis.com). I&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;EM&gt;can&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;guarantee that an ArcGIS Server license will be available, so I think I should be able to run it from ArcGIS Server's Python environment.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;In Visual Studio Code, if I switch to ArcGIS Server's Python environment (C:\Python27\ArcGISx6410.8\python.exe), I get the following error when trying to execute the tool:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp; &amp;nbsp; 'module' object has no attribute 'MyTool_MyToolbox'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;If I call arcpy.ListToolboxes(), the&amp;nbsp;MyToolbox toolbox is one of the toolboxes returned. However, the&amp;nbsp;MyTool&amp;nbsp;tool is not returned by arcpy.ListTools().&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;I've verified that I can list the tool in ArcGIS Pro's Python environment.&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;ArcGIS Pro 2.5.1&lt;/SPAN&gt;&lt;BR style="color: #4c4c4c; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;ArcGIS Server 10.8&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-list-custom-toolbox-in-arcgis-server-s/m-p/683925#M52943</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T16:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can't list custom toolbox in ArcGIS Server's Python environment.</title>
      <link>https://community.esri.com/t5/python-questions/can-t-list-custom-toolbox-in-arcgis-server-s/m-p/683926#M52944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Answer provided by &lt;A href="https://community.esri.com/migrated-users/28964"&gt;Amr Eldib&lt;/A&gt;‌:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #201f1e; background-color: #ffffff;"&gt;I suspect it's because ArcGIS Pro uses Python 3.x while you're attempting to use Python 2.7&lt;/SPAN&gt;&lt;BR style="color: #201f1e; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #201f1e; background-color: #ffffff;"&gt;ArcGIS Server&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A data-auth="NotApplicable" href="https://support.esri.com/en/technical-article/000013224" rel="noopener noreferrer" style="background-color: #ffffff; border: 0px;" target="_blank"&gt;ships with Python 3.x&lt;/A&gt;&lt;SPAN style="color: #201f1e; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as well&lt;/SPAN&gt;&lt;BR style="color: #201f1e; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #201f1e; background-color: #ffffff;"&gt;It should be found at&amp;nbsp;&lt;/SPAN&gt;&lt;EM style="color: #201f1e; background-color: #ffffff;"&gt;C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3&lt;/EM&gt;&lt;SPAN style="color: #201f1e; background-color: #ffffff;"&gt;&amp;nbsp;if you used the default install location.&lt;/SPAN&gt;&lt;BR style="color: #201f1e; background-color: #ffffff;" /&gt;&lt;SPAN style="color: #201f1e; background-color: #ffffff;"&gt;Try using the Python.exe at that location and see if that resolves the issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Switching to ArcGIS Server's Python 3.x environment solved the problem.&amp;nbsp;&lt;/P&gt;&lt;PRE __default_attr="info" __jive_macro_name="alert" alert="info" class="jive_text_macro jive_macro_alert" modifiedtitle="true"&gt;&lt;P&gt;Visual Studio Code &lt;A href="https://code.visualstudio.com/docs/python/environments#_where-the-extension-looks-for-environments"&gt;doesn't automatically detect this Python environment&lt;/A&gt;, so you'll need to manually select this environment, or use one of the methods identified in the link to get Visual Studio Code to automatically detect it.&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2020 11:46:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-list-custom-toolbox-in-arcgis-server-s/m-p/683926#M52944</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-07-08T11:46:20Z</dc:date>
    </item>
  </channel>
</rss>

