<?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: Importing a Python Toolbox (ArcGIS Pro 2.9) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167013#M64377</link>
    <description>&lt;P&gt;Thanks Dan. It does have an alias.&lt;/P&gt;&lt;P&gt;While double checking, I decided to check something else and I think I found the problem. I'm importing separate .py files into my Python toolbox (like the &lt;A href="https://www.arcgis.com/home/item.html?id=3528bd72847c439f88190a137a1d0e67" target="_self"&gt;Spatial Analyst Supplemental Tools&lt;/A&gt;). I took that part out and it seems to import fine.&lt;/P&gt;&lt;P&gt;Ultimately what I'm trying to do is have a Python toolbox with some basic utility functions used by many tools. Each tool is saved as a separate .py file and imported into the Python toolbox. I would like to be able to call functions defined in the Python Toolbox from the separate, imported .py scripts. Testing&amp;nbsp; arcpy.ImportToolbox() was just the first step.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2022 14:21:43 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2022-04-22T14:21:43Z</dc:date>
    <item>
      <title>Importing a Python Toolbox (ArcGIS Pro 2.9)</title>
      <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1166886#M64375</link>
      <description>&lt;P&gt;I'm not sure what I'm doing wrong with&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/importtoolbox.htm" target="_self"&gt;arcpy.ImportToolbox()&lt;/A&gt;&amp;nbsp;in ArcGIS Pro 2.9. No matter what I do, it always errors with&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;OSError: The toolbox file C:\temp\MyToolbox.pyt was not found.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;There's not much to it besides calling&amp;nbsp;arcpy.ImportToolbox(). What am I missing?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 23:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1166886#M64375</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-04-21T23:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a Python Toolbox (ArcGIS Pro 2.9)</title>
      <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1166902#M64376</link>
      <description>&lt;P&gt;Does it have an alias?&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/importtoolbox.htm" target="_blank" rel="noopener"&gt;ImportToolbox—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If the toolbox does not have an alias, the&amp;nbsp;module_name&amp;nbsp;is required.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;See the example&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/a-quick-tour-of-python-toolboxes.htm" target="_blank" rel="noopener"&gt;What is a Python toolbox?—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 00:26:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1166902#M64376</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-04-22T00:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a Python Toolbox (ArcGIS Pro 2.9)</title>
      <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167013#M64377</link>
      <description>&lt;P&gt;Thanks Dan. It does have an alias.&lt;/P&gt;&lt;P&gt;While double checking, I decided to check something else and I think I found the problem. I'm importing separate .py files into my Python toolbox (like the &lt;A href="https://www.arcgis.com/home/item.html?id=3528bd72847c439f88190a137a1d0e67" target="_self"&gt;Spatial Analyst Supplemental Tools&lt;/A&gt;). I took that part out and it seems to import fine.&lt;/P&gt;&lt;P&gt;Ultimately what I'm trying to do is have a Python toolbox with some basic utility functions used by many tools. Each tool is saved as a separate .py file and imported into the Python toolbox. I would like to be able to call functions defined in the Python Toolbox from the separate, imported .py scripts. Testing&amp;nbsp; arcpy.ImportToolbox() was just the first step.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 14:21:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167013#M64377</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-04-22T14:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a Python Toolbox (ArcGIS Pro 2.9)</title>
      <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167020#M64379</link>
      <description>&lt;P&gt;And to clarify further, I currently have the utility functions in their own .py file that is imported into each individual tool's .py file. This is working, but I'd like it to be in the Python toolbox .pyt file so I can encrypt it.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 14:42:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167020#M64379</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-04-22T14:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a Python Toolbox (ArcGIS Pro 2.9)</title>
      <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167084#M64380</link>
      <description>&lt;P&gt;I don't have that problem with "custom" toolboxes.&amp;nbsp; It may be a solution.&amp;nbsp; Although, I tend to have my own *.py file imported by the toolbox, which may contain esri tools, rather than importing them directly&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 16:20:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167084#M64380</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-04-22T16:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a Python Toolbox (ArcGIS Pro 2.9)</title>
      <link>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167750#M64403</link>
      <description>&lt;P&gt;Here's sample code that worked in ArcMap, but I have not tested in Pro.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# standard python toolbox formatting for your utility toolbox
# C:/path/to/this/toolbox.pyt
class Toolbox(object):
    def __init__(self):
        self.label = 'your label'
        self.alias = 'some_alias'
        self.tools = [tool1, tool2, tool3]

# later on when you want to call them, e.g. from another .pyt
ImportToolbox(input_file='C:/path/to/this/toolbox.pyt')
arcpy.some_alias.tool1(arg1, arg2, ...)
arcpy.some_alias.tool2(arg1, ...)
arcpy.some_alias.tool3(arg1, ...)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Apr 2022 22:27:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importing-a-python-toolbox-arcgis-pro-2-9/m-p/1167750#M64403</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-04-25T22:27:27Z</dc:date>
    </item>
  </channel>
</rss>

