<?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 Newbie question: script works in ArcGIS Python window but not from DOS prompt in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32120#M2540</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, I give up: Here's a very simple script which, when entered line by line in the Python window within ArcGIS 10, works just fine. It reports, correctly, that the specified feature class exists. However, when the exact same file is run from the command line, on the same machine, in the same session, it reports the feature class does not exist. No Python errors are reported in either environment. The FC lives in an SDE/SQL Server environment on a remote server, has real data, makes real maps, ... Is it a permissions issue somehow? Is there something else I need to set in the environment when running it from the command line? Other?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;= M =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;&lt;BR /&gt;env.workspace = "Database Connections/Whatever - Else"&lt;BR /&gt;fc = "Testenv.SDE.testFC"&lt;BR /&gt;&lt;BR /&gt;if arcpy.Exists(fc): &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "This exists: %s" % fc &lt;BR /&gt;else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "This does not exist: %s" % fc&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jun 2011 23:39:26 GMT</pubDate>
    <dc:creator>MarchandDupris</dc:creator>
    <dc:date>2011-06-29T23:39:26Z</dc:date>
    <item>
      <title>Newbie question: script works in ArcGIS Python window but not from DOS prompt</title>
      <link>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32120#M2540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, I give up: Here's a very simple script which, when entered line by line in the Python window within ArcGIS 10, works just fine. It reports, correctly, that the specified feature class exists. However, when the exact same file is run from the command line, on the same machine, in the same session, it reports the feature class does not exist. No Python errors are reported in either environment. The FC lives in an SDE/SQL Server environment on a remote server, has real data, makes real maps, ... Is it a permissions issue somehow? Is there something else I need to set in the environment when running it from the command line? Other?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;= M =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;&lt;BR /&gt;env.workspace = "Database Connections/Whatever - Else"&lt;BR /&gt;fc = "Testenv.SDE.testFC"&lt;BR /&gt;&lt;BR /&gt;if arcpy.Exists(fc): &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "This exists: %s" % fc &lt;BR /&gt;else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "This does not exist: %s" % fc&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2011 23:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32120#M2540</guid>
      <dc:creator>MarchandDupris</dc:creator>
      <dc:date>2011-06-29T23:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question: script works in ArcGIS Python window but not from DOS prompt</title>
      <link>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32121#M2541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try adding .sde to the end of the name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2011 23:50:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32121#M2541</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-06-29T23:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question: script works in ArcGIS Python window but not from DOS prompt</title>
      <link>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32122#M2542</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;Thanks for your reply. It wasn't clear which name the '.sde' should be added to, so I tried the various combinations of the env.workspace and the 'fc' variable. Neither worked. Which did you mean?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When working on this problem some more within ArcGIS 10.0 some more, I noticed something else. Within ArcGIS the script only works if I have an MXD file open which uses the feature class in question. If I do a "File / New / Blank map" and run the script as is, it says the feature class does not exist. This makes me wonder if there are other environment/permission/security parameters which must be set somehow within the script itself. My goal here is to have a stand-alone Python script which can be run independently of an ArcGIS session. Any hints on how to make that happen are most welcome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;= M =&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2011 15:00:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32122#M2542</guid>
      <dc:creator>MarchandDupris</dc:creator>
      <dc:date>2011-06-30T15:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question: script works in ArcGIS Python window but not from DOS prompt</title>
      <link>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32123#M2543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wonder if it's necessary to give the complete path to the SDE connection file, not just "Database Connections..." but "C:/Documents and Settings/.../Database Connections/..." or wherever the location is.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2011 15:49:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32123#M2543</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2011-07-01T15:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question: script works in ArcGIS Python window but not from DOS prompt</title>
      <link>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32124#M2544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;OK, I give up: Here's a very simple script which, when entered line by line in the Python window within ArcGIS 10, works just fine. It reports, correctly, that the specified feature class exists. However, when the exact same file is run from the command line, on the same machine, in the same session, it reports the feature class does not exist. No Python errors are reported in either environment. The FC lives in an SDE/SQL Server environment on a remote server, has real data, makes real maps, ... Is it a permissions issue somehow? Is there something else I need to set in the environment when running it from the command line? Other?&lt;BR /&gt;&lt;BR /&gt;= M =&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;&lt;BR /&gt;env.workspace = "Database Connections/Whatever - Else"&lt;BR /&gt;fc = "Testenv.SDE.testFC"&lt;BR /&gt;&lt;BR /&gt;if arcpy.Exists(fc): &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "This exists: %s" % fc &lt;BR /&gt;else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "This does not exist: %s" % fc&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if you set the database connection as the default gdb in arccatalog&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;then&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = env.workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "%s" % fc&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you will see exactly what it expects for the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;fcs = arcpy.listfeatureclasses()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print fcs&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;will return the list of feature classes in the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lds = arcpy.listdatasets()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print lds&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;will return a list of the datasets&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2011 17:39:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/newbie-question-script-works-in-arcgis-python/m-p/32124#M2544</guid>
      <dc:creator>SigiSharp</dc:creator>
      <dc:date>2011-08-02T17:39:34Z</dc:date>
    </item>
  </channel>
</rss>

