<?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: ArcGIS 10.1 python script to exe is not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479765#M37530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's kind of amazing that a py2exe script that used arcgisscripting/arcpy ever worked this way at all. What looks like is happening is the DLL is loading the wrong version (python 2.7 loading a python 2.6 PYD, or a 10.0 arcgisscripting.pyd trying to load 10.1 DLLs into the process), or much more likely, py2exe isn't bringing over everything it needs. I'd assume it to be difficult to the point of it not being worth it to include the full binary distribution of the subset of arcobjects needed to do what you need, or some hack with __import__ and the registry to find and add the ArcGIS installation directory to Python's path to load the installed arcgisscripting without triggering py2exe's import consolidation mechanics which is creating this strange condition. &lt;/SPAN&gt;&lt;A href="http://www.py2exe.org/index.cgi/ExcludingDlls"&gt;You'll need to exclude arcgisscripting in your build script&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why exactly are you converting a script to executable? To obscure the source? That can be done more easily by embedding the script in your toolbox and password protecting it, or distributing bytecode (.pyc) files you call indirectly from your script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Aug 2012 18:58:09 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2012-08-15T18:58:09Z</dc:date>
    <item>
      <title>ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479764#M37529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I updated my python script from ArcGIS 9.3 Python 2.5 to ArcGIS 10.1 Python 2.7. The script is working from python 2.7 GUI, however, when I converted to exe by py2exe, and then ran the exe, I got the following errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Python27\ArcGIS10.1\dist&amp;gt;SDEGetLatLongOfAProjectedPoint.exe&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "SDEGetLatLongOfAProjectedPoint.py", line 1, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcpy\__init__.pyc", line 21, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcpy\geoprocessing\__init__.pyc", line 14, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcpy\geoprocessing\_base.pyc", line 14, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcgisscripting.pyc", line 12, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcgisscripting.pyc", line 10, in __load&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ImportError: DLL load failed: The specified procedure could not be found.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have 2 PCs, one pc is for ArcGIS 9.3.1 with python 2.5. the other for ArcGIS 10.1 with Python 2.7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, my python 2.5 script converted to the exe, which is working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My Python 2.7 and py2exe for Python 2.7 is working. I created a generic python script (without using any import arcpy libraries), and converted it to the exe, which is working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:12:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479764#M37529</guid>
      <dc:creator>SteveXu</dc:creator>
      <dc:date>2012-08-15T18:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479765#M37530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's kind of amazing that a py2exe script that used arcgisscripting/arcpy ever worked this way at all. What looks like is happening is the DLL is loading the wrong version (python 2.7 loading a python 2.6 PYD, or a 10.0 arcgisscripting.pyd trying to load 10.1 DLLs into the process), or much more likely, py2exe isn't bringing over everything it needs. I'd assume it to be difficult to the point of it not being worth it to include the full binary distribution of the subset of arcobjects needed to do what you need, or some hack with __import__ and the registry to find and add the ArcGIS installation directory to Python's path to load the installed arcgisscripting without triggering py2exe's import consolidation mechanics which is creating this strange condition. &lt;/SPAN&gt;&lt;A href="http://www.py2exe.org/index.cgi/ExcludingDlls"&gt;You'll need to exclude arcgisscripting in your build script&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why exactly are you converting a script to executable? To obscure the source? That can be done more easily by embedding the script in your toolbox and password protecting it, or distributing bytecode (.pyc) files you call indirectly from your script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:58:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479765#M37530</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-08-15T18:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479766#M37531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I completely agree with you. My ArcGIS 10.1 python 2.7 XP PC is not a clean pc. I removed the old ArcGIS9.3/10.0, however, which didn't clean everything. So I will use a clean PC with a fresh ArcGIS 10.1 to do the test.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just used to use py2exe to create the exe for our internal users. Most of them are running as windows' scheduled tasks. However, I'm open to any suggestions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your insights on this issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 19:12:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479766#M37531</guid>
      <dc:creator>SteveXu</dc:creator>
      <dc:date>2012-08-15T19:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479767#M37532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jason:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just came cross this website &lt;/SPAN&gt;&lt;A href="http://popdevelop.com/2010/04/how-to-build-an-executable-application-from-your-python-script-qt-special/"&gt;http://popdevelop.com/2010/04/how-to-build-an-executable-application-from-your-python-script-qt-special/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on Mike's post on the website, Looks like I need to add some ArcGIS dlls in my setup.py. DO you have any insights on this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I am using ArcGIS 9.3.1 with Python 2.5 and py2exe, I don't need to exclude/include any ArcGIS dlls. I only need to exclude 'MSVCP90.dll' in the setup.py.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 20:14:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479767#M37532</guid>
      <dc:creator>SteveXu</dc:creator>
      <dc:date>2012-08-15T20:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479768#M37533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah, I'm not entirely sure what is going on. You might want to compare the logs and manifests of either when they create the executable and bundle it all together. Hopefully the list of files included is roughly the same but one or two obvious additions or omissions that are the culprits.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A lot has changed under the hood in the architecture in ArcGIS since 9.3.1, hence my surprise that it ever worked at all.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 20:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479768#M37533</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-08-15T20:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479769#M37534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "splitMain.py", line 11, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "splitUI.pyc", line 11, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "test2.pyc", line 18, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcpy\__init__.pyc", line 21, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcpy\geoprocessing\__init__.pyc", line 14, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcpy\geoprocessing\_base.pyc", line 14, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcgisscripting.pyc", line 12, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "arcgisscripting.pyc", line 10, in __load&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ImportError: DLL load failed: �?�不�?��??�?�??模�?�??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey, how did you solve the problem?Can you please share?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 05:08:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479769#M37534</guid>
      <dc:creator>hcbai</dc:creator>
      <dc:date>2013-08-23T05:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479770#M37535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One workaround for this, so that you can still distribute an exe file, is to make a &lt;/SPAN&gt;&lt;STRONG&gt;wrapper &lt;/STRONG&gt;&lt;SPAN&gt;script which gets converted to exe and distribute it with a &lt;/SPAN&gt;&lt;STRONG&gt;pyc &lt;/STRONG&gt;&lt;SPAN&gt;file that actually does the calculation. For example (very simple, not really recommended, but will work - see below for a better option):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code script: doSomething.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
# do some stuff
# do some more stuff&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wrapper script: wrapper.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import doSomething&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You simply have to run &lt;/SPAN&gt;&lt;STRONG&gt;wrapper.py&lt;/STRONG&gt;&lt;SPAN&gt;, it will import &lt;/SPAN&gt;&lt;STRONG&gt;doSomething.py&lt;/STRONG&gt;&lt;SPAN&gt; and make a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;&lt;STRONG&gt;*.pyc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt; file from it. Then you can use &lt;/SPAN&gt;&lt;STRONG&gt;py2exe &lt;/STRONG&gt;&lt;SPAN&gt;on &lt;/SPAN&gt;&lt;STRONG&gt;wrapper.py&lt;/STRONG&gt;&lt;SPAN&gt;. Then you simply have to keep the &lt;/SPAN&gt;&lt;STRONG&gt;doSomething.pyc&lt;/STRONG&gt;&lt;SPAN&gt; file with the &lt;/SPAN&gt;&lt;STRONG&gt;exe &lt;/STRONG&gt;&lt;SPAN&gt;when you distribute it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG style="text-decoration: underline;"&gt;RECOMMENDED IMPLEMENTATION&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code script: doSomething.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; # do some stuff
&amp;nbsp;&amp;nbsp;&amp;nbsp; # do some more stuff

if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass # will do nothing if someone tries to run it directly
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wrapper script: wrapper.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import doSomething

doSomething.main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:10:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479770#M37535</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T21:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479771#M37536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I &lt;SPAN style="color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15.199999809265137px;"&gt;had the &lt;SPAN style="color: #434343; font-family: Tahoma, Arial; font-size: 12px; font-weight: bold; background-color: #f2f2f2;"&gt;Similar&lt;/SPAN&gt; problem when I &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; using ArcGIS 10.3&amp;nbsp; arcpy with Python 2.7 and cxfreeze to convert .py into exe &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15.199999809265137px;"&gt;&lt;IMG alt="problem.bmp" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/88021_problem.bmp" style="height: auto;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15.199999809265137px;"&gt;can you give me some suggest to solve the problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15.199999809265137px;"&gt;thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="clickable js-inline-clickable" style="color: #35a1d4;"&gt; &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2015 14:15:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479771#M37536</guid>
      <dc:creator>yingjieliu</dc:creator>
      <dc:date>2015-04-22T14:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479772#M37537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stacy's workaround isn't working for me either (with 10.2.2), I'm getting the error message shown in the screenshot when trying to run the exe in the command line.&amp;nbsp; I'm also getting a message in the command line re: missing modules (see screenshot), but am not sure where I can find these...any ideas???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 13:54:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479772#M37537</guid>
      <dc:creator>TrilliumLevine1</dc:creator>
      <dc:date>2015-04-29T13:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS 10.1 python script to exe is not working</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479773#M37538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the exact same problem as&amp;nbsp;&lt;A _jive_internal="true" class="" data-userid="139101" data-username="liuyingjie" href="https://community.esri.com/people/liuyingjie" style="color: #3778c7; background-color: #ffffff; border: 0px; font-weight: 200; text-decoration: underline; font-size: 1.286rem;"&gt;liuyingjie&lt;/A&gt;&amp;nbsp;above, not finding a clear solution.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2020 12:56:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-10-1-python-script-to-exe-is-not-working/m-p/479773#M37538</guid>
      <dc:creator>LaurenPeckman</dc:creator>
      <dc:date>2020-05-28T12:56:49Z</dc:date>
    </item>
  </channel>
</rss>

