<?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: Making .exe from modelbuilder and python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359030#M28328</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should just be able to convert the entire model to a python script which can be run outside of ArcGIS (you would still have to run it on a computer with ArcGIS licensing).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the model you simply need to go to Model&amp;gt;export&amp;gt;to python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From there you probably could integrate it into whatever you need to make it an .exe file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jun 2014 12:38:34 GMT</pubDate>
    <dc:creator>IanMurray</dc:creator>
    <dc:date>2014-06-02T12:38:34Z</dc:date>
    <item>
      <title>Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359029#M28327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully someone with much more experience in Python can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ive got a model which i created in modelbuilder, and in the model there is a Python script( i did NOT do the coding) found it in my company's "Archive".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What i want to know if there is any way i can make the model a stand alone .exe? at this moment i need to be in ArcMap10 to run my model, reason for this is that i want to implement my tool into a InfoPath form i created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So is there any way this is possible?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please tell me if its possible that i can give more info about the tool and what it does&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank You&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jun 2014 12:00:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359029#M28327</guid>
      <dc:creator>RicoKock</dc:creator>
      <dc:date>2014-06-02T12:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359030#M28328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should just be able to convert the entire model to a python script which can be run outside of ArcGIS (you would still have to run it on a computer with ArcGIS licensing).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the model you simply need to go to Model&amp;gt;export&amp;gt;to python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From there you probably could integrate it into whatever you need to make it an .exe file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jun 2014 12:38:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359030#M28328</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-06-02T12:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359031#M28329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You should just be able to convert the entire model to a python script which can be run outside of ArcGIS (you would still have to run it on a computer with ArcGIS licensing).&lt;BR /&gt;&lt;BR /&gt;In the model you simply need to go to Model&amp;gt;export&amp;gt;to python script.&lt;BR /&gt;&lt;BR /&gt;From there you probably could integrate it into whatever you need to make it an .exe file.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the reply, that was the first thing did before coming to the Forums, the Script gives me an error, and me totally new to Python(meaning 0 experience) did not know what to do with the error [ATTACH=CONFIG]34254[/ATTACH].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know its probably a small error, wanting to "impress" my manager by solving this huge problem we have in the company, my tool certainly resolves our issue but without it being an .exe doesnt really do my tool any justice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jun 2014 12:50:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359031#M28329</guid>
      <dc:creator>RicoKock</dc:creator>
      <dc:date>2014-06-02T12:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359032#M28330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ah, it seems the python script you included in the model is probably from arcgis 9.3 or prior, which used different syntax for certain tools then what is being used for 10.0 to current.&amp;nbsp; the gp you see is the older version syntax they used.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you could post the python script that was included in the model, we could probably help you debug or update it so it can run for 10.0 - 10.2&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jun 2014 15:28:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359032#M28330</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-06-02T15:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359033#M28331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;ah, it seems the python script you included in the model is probably from arcgis 9.3 or prior, which used different syntax for certain tools then what is being used for 10.0 to current.&amp;nbsp; the gp you see is the older version syntax they used.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;If you could post the python script that was included in the model, we could probably help you debug or update it so it can run for 10.0 - 10.2&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Thank You so much for reply and helping me, just to add the model runs completely smooth and how its intended to do, in ArcMap 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But here is the script hopefully u guys can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os, sys, random, arcgisscripting
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp = arcgisscripting.create()
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.overwriteoutput = 1

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Specify input featureclass, output *.lyr file and the percentage of
&amp;nbsp;&amp;nbsp;&amp;nbsp; # random points to return. Set these parameters in ArcToolbox as shown.
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputFC = sys.argv[1] # Feature Class or Feature Layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; outputLyr = sys.argv[2] # Layer File
&amp;nbsp;&amp;nbsp;&amp;nbsp; inpct = sys.argv[3] # Long

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Ensure that the input percentage is between 1 and 100%
&amp;nbsp;&amp;nbsp;&amp;nbsp; inpct = min(int(inpct),100)
&amp;nbsp;&amp;nbsp;&amp;nbsp; inpct = max(int(inpct),1)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Work out how many features to select
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputDirname = os.path.dirname(inputFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputBasename = os.path.basename(inputFC)

&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.workspace = inputDirname
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = gp.describe(inputFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp; totpnts = gp.getcount(inputFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp; numValues = int(round(totpnts * float(inpct) / 100.0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addmessage("Selecting " + str(numValues) + " random features")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Generate a list of all features, and select randomly from this
&amp;nbsp;&amp;nbsp;&amp;nbsp; inList = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; randomList = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; fldname = desc.OIDFieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = gp.SearchCursor(inputFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addmessage ("Loading all IDs into a list")
&amp;nbsp;&amp;nbsp;&amp;nbsp; while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id = row.GetValue(fldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inList.append(id)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.next()

&amp;nbsp;&amp;nbsp;&amp;nbsp; selpnts = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addmessage("Creating the list of randomly selected features")
&amp;nbsp;&amp;nbsp;&amp;nbsp; while len(randomList) &amp;lt; numValues:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selpnts += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selItem = random.choice(inList)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; randomList.append(selItem)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inList.remove(selItem)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select features whose OID value occurs in the random list, generate
&amp;nbsp;&amp;nbsp;&amp;nbsp; # a *.lyr file from this selection. (Leading and trailing [ and ] marks
&amp;nbsp;&amp;nbsp;&amp;nbsp; # need to be removed from the list object)
&amp;nbsp;&amp;nbsp;&amp;nbsp; theLen = len(str(randomList))
&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlexp = '"' + fldname + '"' + " in " + "(" + str(randomList)[1:theLen - 1] + ")"
&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLyr = inputBasename + " selection"
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(inputFC, selectionLyr, sqlexp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SaveToLayerFile_management(selectionLyr, outputLyr)

&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addmessage("\nOutput layer " + outputLyr + " contains features randomly selected from " + inputBasename + "\n")
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.adderror("Error running script. Try specifying the full path to the input layer")

# END OF FILE&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:45:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359033#M28331</guid>
      <dc:creator>RicoKock</dc:creator>
      <dc:date>2021-12-11T16:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359034#M28332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure if this is a good idea, but to possibly fix your immediate issue you can try to change this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;import os, sys, random, arcgisscripting&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;import os, sys, random, arcgisscripting &lt;STRONG&gt;as gp&lt;/STRONG&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jun 2014 10:53:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359034#M28332</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-06-03T10:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Making .exe from modelbuilder and python script</title>
      <link>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359035#M28333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi is there any one that had a look at the code and how to debug it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please urgent!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 10:51:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/making-exe-from-modelbuilder-and-python-script/m-p/359035#M28333</guid>
      <dc:creator>RicoKock</dc:creator>
      <dc:date>2014-06-05T10:51:25Z</dc:date>
    </item>
  </channel>
</rss>

