<?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: Installing Python module from within code inside ArcGIS Pro script tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/installing-python-module-from-within-code-inside/m-p/305634#M23725</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are running Pro 2.2... you will have issues since the environment is in lockdown&lt;/P&gt;&lt;P&gt;Search GeoNet using 'conda' as the keyword for the last 30 days to see the various discussions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Jul 2018 19:37:19 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-07-09T19:37:19Z</dc:date>
    <item>
      <title>Installing Python module from within code inside ArcGIS Pro script tool</title>
      <link>https://community.esri.com/t5/python-questions/installing-python-module-from-within-code-inside/m-p/305633#M23724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;I am trying to install a third-party Python package from within a Python script so that other users can run the script and the package can be installed and loaded without having to manually download and install. This is the code I'm using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import&lt;/SPAN&gt;&lt;SPAN class=""&gt; subprocess
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;def&lt;/SPAN&gt;&lt;SPAN class=""&gt; install&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;package&lt;/SPAN&gt;&lt;SPAN class=""&gt;):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;subprocess&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;call&lt;/SPAN&gt;&lt;SPAN class=""&gt;([&lt;/SPAN&gt;&lt;SPAN class=""&gt;sys&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;executable&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;"-m"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;'pip'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;'install'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt; package&lt;/SPAN&gt;&lt;SPAN class=""&gt;])
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;install&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'pyodbc'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class=""&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;import&lt;/SPAN&gt;&lt;SPAN class=""&gt; pyodbc

&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This seems to work fine from within my stand-alone Python script. However, when I try to run it as a script tool set up in ArcGIS Pro, it is not finding the installed package and is failing with this error message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ModuleNotFoundError&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;No&lt;/SPAN&gt;&lt;SPAN class=""&gt; module named &lt;/SPAN&gt;&lt;SPAN class=""&gt;'pyodbc'

&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does anyone know what the issue is? Do I need to change a path or environment setting?&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:38:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/installing-python-module-from-within-code-inside/m-p/305633#M23724</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2021-12-11T14:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Installing Python module from within code inside ArcGIS Pro script tool</title>
      <link>https://community.esri.com/t5/python-questions/installing-python-module-from-within-code-inside/m-p/305634#M23725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are running Pro 2.2... you will have issues since the environment is in lockdown&lt;/P&gt;&lt;P&gt;Search GeoNet using 'conda' as the keyword for the last 30 days to see the various discussions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jul 2018 19:37:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/installing-python-module-from-within-code-inside/m-p/305634#M23725</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-07-09T19:37:19Z</dc:date>
    </item>
  </channel>
</rss>

