<?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: Dumb question - can I write standalone python script to run without arcgis? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318659#M11191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, tried running it in python shell and got this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; mxd=arcpy.mapping.MapDocument("I:\GIS_Workspace\Ventura_Area\Danny\SAPTList.mxd") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView();arcpy.RefreshTOC() &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.ExportToPDF (mxd,"I:\GIS_Workspace\Ventura_Area\Danny\SAPT_MAP.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File "&amp;lt;pyshell#2&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mxd=arcpy.mapping.MapDocument("I:\GIS_Workspace\Ventura_Area\Danny\SAPTList.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NameError: name 'arcpy' is not defined&amp;gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, this SAME script run beautifully in ArcGIS.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jan 2012 20:16:43 GMT</pubDate>
    <dc:creator>DannyLackey</dc:creator>
    <dc:date>2012-01-11T20:16:43Z</dc:date>
    <item>
      <title>Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318633#M11165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to open a raster, thin it, and save it. Can I do that in a script outside of arcgis, or does arcgis need to be running for the script to work? I have it installed on the system, so it would obviously be running on my computer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry this question is really simple. I don't really understand how to run a script outside of arcgis...or even if it's possible. I'm hoping someone will say yes or no! Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 06:54:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318633#M11165</guid>
      <dc:creator>jimparsons</dc:creator>
      <dc:date>2010-05-19T06:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318634#M11166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;nope. You do not need to have arcgis open, you can call geoprocessing from within the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 08:01:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318634#M11166</guid>
      <dc:creator>ToreBorvik</dc:creator>
      <dc:date>2010-05-19T08:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318635#M11167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe it is possible. Just write a Python script as if it were run from within ArcGIS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Run it from within a dos-prompt: &amp;lt;name_script.py&amp;gt; &amp;lt;param1&amp;gt; &amp;lt;param2&amp;gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Works for me, so I think it should work for you as well. But only just as long you have ArcGIS installed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Koen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 11:03:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318635#M11167</guid>
      <dc:creator>KoenVolleberg</dc:creator>
      <dc:date>2010-05-19T11:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318636#M11168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Absolutely, I run all my python scripts without ArcMap open, from a command line.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 16:59:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318636#M11168</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2010-05-19T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318637#M11169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Another way to run them outside of ArcGIS or the command prompt is just to open them in an IDE (python editing program) and run them from there.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 18:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318637#M11169</guid>
      <dc:creator>JoelCalhoun</dc:creator>
      <dc:date>2010-05-19T18:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318638#M11170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you. I find the model builder great for building, but not great for naming the files that inevitably crop up. I use the scratch space thing, but I think I could do a better job programmatically creating new folders based on time and date. I'm pretty confident I can do that in python...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 21:30:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318638#M11170</guid>
      <dc:creator>jimparsons</dc:creator>
      <dc:date>2010-05-19T21:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318639#M11171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's another kinda dumb question. How hard would it be to write a script to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;do&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; zoom to layer for each raster in document&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; file -&amp;gt; export map based on current extent&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;loop for each raster in doc&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With python it's easy to access the toolbox, but how would we access a) the zoom to layer command, and b) the file export map tool, which is a very handy way to effectively merge lots of 24 bit color rasters simply by opening them all and exporting the overall map at great resolution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this instance I want to zoom to layer of each one so I can export them as a geotiff, not as tif + tfw as they are at the moment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have no idea how difficult the above job is. Can anyone tell me? Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 May 2010 22:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318639#M11171</guid>
      <dc:creator>jimparsons</dc:creator>
      <dc:date>2010-05-19T22:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318640#M11172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not easy at least. I've not succeeded in making arcmap zoom around in a document from a script. But I'm no script pro..&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 May 2010 08:04:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318640#M11172</guid>
      <dc:creator>ToreBorvik</dc:creator>
      <dc:date>2010-05-20T08:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318641#M11173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Life would be much easier if we could record batch macros like in Photoshop.....without having to write arcobjects script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 May 2010 08:59:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318641#M11173</guid>
      <dc:creator>jimparsons</dc:creator>
      <dc:date>2010-05-20T08:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318642#M11174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcGIS 10 will include &lt;/SPAN&gt;&lt;STRONG&gt;arcpy.mapping&lt;/STRONG&gt;&lt;SPAN&gt;.&amp;nbsp; It will allow for the maipulation of layer files, aspects of the layout, map &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;automation, and export with Python.&amp;nbsp; The added functionality might enable you to do what you want.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 May 2010 19:00:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318642#M11174</guid>
      <dc:creator>JoelCalhoun</dc:creator>
      <dc:date>2010-05-24T19:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318643#M11175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;"With python it's easy to access the toolbox, but how would we access a) the zoom to layer command, and b) the file export map tool, which is a very handy way to effectively merge lots of 24 bit color rasters simply by opening them all and exporting the overall map at great resolution."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Jim, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wandering if you were successful in writing that python script.I am trying to do something similar. I'd apprecaite you reply, thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Nov 2010 20:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318643#M11175</guid>
      <dc:creator>BartKowalski</dc:creator>
      <dc:date>2010-11-02T20:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318644#M11176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It just needs to be present on the computer.&amp;nbsp; It need not be running but arcpy needs to be imported which means it must be on the computer.&amp;nbsp; gp.Addmessage statements need to be replaced with print statements.&amp;nbsp; The following is an example&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
'''
CreatePolyDemo.py

Demonstrates calculating various properties for polygons

'''
import arcpy
pnt = arcpy.Point()

triangle = [[0,0],[0,1],[1,0]]
square = [[0,0],[0,1],[1,1],[1,0]]
rectangle = [[0,0],[0,1],[2,1],[2,0]]
polygons = [triangle, square, rectangle]
labels = ["Triangle", "Square", "Rectangle"]
array = arcpy.Array()
polys = []
for i in range(len(polygons)):
&amp;nbsp; a_poly = polygons&lt;I&gt;
&amp;nbsp; print "\n", labels&lt;I&gt;," Coordinates: ", a_poly
&amp;nbsp; for pair in a_poly:
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.X = pair[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.Y = pair[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print " X %20.16f&amp;nbsp; Y %20.16f" % (pnt.X, pnt.Y)
&amp;nbsp; array.add(array.getObject(0))
&amp;nbsp; poly = arcpy.Polygon(array)
&amp;nbsp; print "Polygon properties:"
&amp;nbsp; print " area %20.16f\n length %s" % (poly.area, poly.length)
&amp;nbsp; print " centroid %s\n true centroid %s " % (poly.centroid, poly.trueCentroid) 
&amp;nbsp; print " first point %s\n last point %s " % (poly.firstPoint, poly.lastPoint)
&amp;nbsp; print " extent %s " % (poly.extent)
&amp;nbsp; print " hull %s\n " % (poly.hullRectangle)
&amp;nbsp; array.removeAll()
&amp;nbsp; polys.append(poly)
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318644#M11176</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T15:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318645#M11177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bart, Those are methods of the arcpy.mapping class. Its actually very easy once you read over the docs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Geoprocessing_scripts_for_map_document_management_and_output/00s300000032000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Geoprocessing_scripts_for_map_document_management_and_output/00s300000032000000/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 12:05:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318645#M11177</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-11-03T12:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318646#M11178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It just needs to be present on the computer.&amp;nbsp; It need not be running but arcpy needs to be imported which means it must be on the computer.&amp;nbsp; gp.Addmessage statements need to be replaced with print statements.&amp;nbsp; The following is an example&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
'''
CreatePolyDemo.py

Demonstrates calculating various properties for polygons

'''
import arcpy
pnt = arcpy.Point()

triangle = [[0,0],[0,1],[1,0]]
square = [[0,0],[0,1],[1,1],[1,0]]
rectangle = [[0,0],[0,1],[2,1],[2,0]]
polygons = [triangle, square, rectangle]
labels = ["Triangle", "Square", "Rectangle"]
array = arcpy.Array()
polys = []
for i in range(len(polygons)):
&amp;nbsp; a_poly = polygons&lt;I&gt;
&amp;nbsp; print "\n", labels&lt;I&gt;," Coordinates: ", a_poly
&amp;nbsp; for pair in a_poly:
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.X = pair[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt.Y = pair[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; array.add(pnt)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print " X %20.16f&amp;nbsp; Y %20.16f" % (pnt.X, pnt.Y)
&amp;nbsp; array.add(array.getObject(0))
&amp;nbsp; poly = arcpy.Polygon(array)
&amp;nbsp; print "Polygon properties:"
&amp;nbsp; print " area %20.16f\n length %s" % (poly.area, poly.length)
&amp;nbsp; print " centroid %s\n true centroid %s " % (poly.centroid, poly.trueCentroid) 
&amp;nbsp; print " first point %s\n last point %s " % (poly.firstPoint, poly.lastPoint)
&amp;nbsp; print " extent %s " % (poly.extent)
&amp;nbsp; print " hull %s\n " % (poly.hullRectangle)
&amp;nbsp; array.removeAll()
&amp;nbsp; polys.append(poly)
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage() will just print to console if the script was not called from ArcMap&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:09:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318646#M11178</guid>
      <dc:creator>FrankPerks</dc:creator>
      <dc:date>2021-12-11T15:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318647#M11179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Frank...unfortunately it doesn't print to other IDE's output...don't use console...too dark and gloomy and reminds me of the old DOS days&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 19:17:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318647#M11179</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-11-03T19:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318648#M11180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Frank...unfortunately it doesn't print to other IDE's output...don't use console...too dark and gloomy and reminds me of the old DOS days&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's for that reason that I wrote my own message(), warning() and error() methods. In addition to logging to a text file, it's exactly 3 places that I need to change if I need print statements or not, not dozens of lines littered throughout the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Most of the time I don't need print messages, but if I'm debugging in PyScripter or PythonWin (but not winpdb which runs the script in a separate console window from the GUI), I'll uncomment my print statement in each of the 3 methods.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Helper methods for writing messages, warnings and errors to the geoprocessor as well as a logfile
# By default, prepends a timestamp to the message; set second argument to 0 or False to disable
def message(strMessage, stamp = True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp, logFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; if stamp == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMessage = time.asctime() + " - " + strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage(strMessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if logFile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.write(strMessage + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.flush()

def warning(strMessage, stamp = True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp, logFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; if stamp == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMessage = time.asctime() + " - " + strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddWarning(strMessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if logFile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.write(strMessage + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.flush()

def error(strMessage, stamp = True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp, logFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; if stamp == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMessage = time.asctime() + " - " + strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddError(strMessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if logFile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.write(strMessage + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.flush()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:09:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318648#M11180</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2021-12-11T15:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318649#M11181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Logan&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;good suggestion...and you need not even comment out the print statement, in fact you could get ready for python 3.0 by adding these blocks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print strMessage&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #pre 3.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; except&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (strMessage)&amp;nbsp;&amp;nbsp; #3.0 +&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage(strMessage)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the print statement will simply become heat energy if gp is being used and vica versa.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 20:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318649#M11181</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-11-03T20:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318650#M11182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Frank...unfortunately it doesn't print to other IDE's output...don't use console...too dark and gloomy and reminds me of the old DOS days&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank" rel="nofollow noopener noreferrer"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;IMG src="http://imgur.com/D1RSw.png" /&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pycharm / Komodo python IDE's are fine with the message printing(I assume wingide is too) :cool: IDLE/pywin32 is not an IDE, they are mistakes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you really want a decent Python IDE i honestly suggest looking into PyCharm (try it for 30 days, its also 50% off right now). If you don't want to spend money then i suggest NetBeans, or PyScripter. (I refuse to acknowledge pydev since its based off the horror that is known as eclipse).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It's for that reason that I wrote my own message(), warning() and error() methods. In addition to logging to a text file, it's exactly 3 places that I need to change if I need print statements or not, not dozens of lines littered throughout the script.&lt;BR /&gt;&lt;BR /&gt;Most of the time I don't need print messages, but if I'm debugging in PyScripter or PythonWin (but not winpdb which runs the script in a separate console window from the GUI), I'll uncomment my print statement in each of the 3 methods.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Helper methods for writing messages, warnings and errors to the geoprocessor as well as a logfile
# By default, prepends a timestamp to the message; set second argument to 0 or False to disable
def message(strMessage, stamp = True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp, logFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; if stamp == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMessage = time.asctime() + " - " + strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage(strMessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if logFile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.write(strMessage + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.flush()

def warning(strMessage, stamp = True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp, logFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; if stamp == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMessage = time.asctime() + " - " + strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddWarning(strMessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if logFile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.write(strMessage + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.flush()

def error(strMessage, stamp = True):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global gp, logFile
&amp;nbsp;&amp;nbsp;&amp;nbsp; if stamp == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strMessage = time.asctime() + " - " + strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print strMessage
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddError(strMessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if logFile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.write(strMessage + "\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logFile.flush()&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You should really look into the python logging, its wonderful: &lt;/SPAN&gt;&lt;A href="http://docs.python.org/library/logging.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://docs.python.org/library/logging.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However you need to create a gp friendly logger... heres an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import logging
import sys


_GP_MESSAGE_DEFS = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.CRITICAL : "AddError",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.ERROR : "AddError",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.WARNING : "AddWarning",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.INFO : "AddMessage",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.DEBUG : "AddMessage",
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

class GPHandler(logging.Handler):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Geoprocessor friendly logging module
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self, level=logging.NOTSET, gp=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.gp = gp
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.Handler.__init__(self, level)

&amp;nbsp;&amp;nbsp;&amp;nbsp; def emit(self, record):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Woop.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = self.format(record)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if self.gp:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source = gp
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source = __import__("arcpy")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # retrive the functor and call it with the message
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getattr(source, _GP_MESSAGE_DEFS[record.levelno])(message)

_logger = logging.getLogger("test")
_logger.setLevel(logging.DEBUG)

# sadily i have no idea where this object type is located
if type(sys.stdout) != "&amp;lt;type 'geoprocessing sys.stdout object'&amp;gt;":
&amp;nbsp;&amp;nbsp;&amp;nbsp; handler = logging.StreamHandler()
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # change for arc9.3
&amp;nbsp;&amp;nbsp;&amp;nbsp; handler = GPHandler()

handler.setFormatter(logging.Formatter("%(asctime)10s | %(name)s | %(message)s",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "%Y%m%d %H:%M:%S"))
_logger.addHandler(handler)

_logger.debug("Message")
_logger.info("Info message")
_logger.warning("Warning")
_logger.error("error")
_logger.critical("error")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This gives an output of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
20101103 21:36:45 | test | Message
20101103 21:36:52 | test | Info message
WARNING: 20101103 21:36:52 | test | Warning
ERROR: 20101103 21:36:52 | test | error
ERROR: 20101103 21:36:52 | test | error
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you run it from not within arcmap it goes to normal console streams. If you run it via arcgis it goes to the gp addmessage/etc.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:09:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318650#M11182</guid>
      <dc:creator>FrankPerks</dc:creator>
      <dc:date>2021-12-11T15:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318651#M11183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;print x is a syntax error in Python 3.0, so you're not future-proofing your code nearly as well as you think.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Starting from 2.6, you can import print as a function from the future with from __future__ import print_function directive and use print as a 3.x style function across the board in your script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 00:42:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318651#M11183</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2010-11-04T00:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dumb question - can I write standalone python script to run without arcgis?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318652#M11184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;SPAN style="font-family:&amp;quot;Courier New&amp;quot;;"&gt;print x&lt;/SPAN&gt; is a syntax error in Python 3.0, so you're not future-proofing your code nearly as well as you think.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Starting from 2.6, you can import print as a function from the future with&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family:&amp;quot;Courier New&amp;quot;;"&gt;from __future__ import print_function&lt;/SPAN&gt; directive and use print as a 3.x style function across the board in your script.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also by doing the from __future__ import print_function, you add some amazing functionality in the form of completely breaking any chance of the 9.3 or less crowd from using your script (which is a big reality considering how many people probably still use &amp;lt; 10.0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you reallllyyyyyy want to futureproof print (because esri is bound to go to python 3.0 any day now :o). Don't use it. Use logging. Or use sys.stdout.write(). Or even just use ESRI's AddMessage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Print is evil.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 01:16:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/dumb-question-can-i-write-standalone-python-script/m-p/318652#M11184</guid>
      <dc:creator>FrankPerks</dc:creator>
      <dc:date>2010-11-04T01:16:38Z</dc:date>
    </item>
  </channel>
</rss>

