<?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 Script won't run outside of ArcMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616511#M48108</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am fairly new to Python, but I'm having an issue running a script. It runs fine when I use the python window in ArcMap, but when I try to run the same script either from double clicking a .py file, or running in the IDLE window, I get an error. I know I can easily do this just using select by attributes in ArcMap, but I'm trying to learn more python to automate more things down the road, this is a first test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

tree = r"M:\\Temp\ArcPy\Tree.shp"
arcpy.env.overwriteOutput=True 
arcpy.MakeFeatureLayer_management(tree, "Tree")
arcpy.SelectLayerByAttribute_management("Tree","NEW_SELECTION",' "Diameter" &amp;gt;=50')
arcpy.CopyFeatures_management ("Tree","Trees50DBH")
arcpy.FeatureClassToFeatureClass_conversion("TreesGreater50DBH",r"M:\\Temp\ArcPy","Tree50DBH")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Error (happens at the arcpy.CopyFeatures_management code)&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "M:\Temp\ArcPY\TreeArcPyTest.py", line 12, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management ("Tree","Trees50DBH")&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 2434, in CopyFeatures&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000210: Cannot create output Trees50DBH&lt;/P&gt;&lt;P&gt;Failed to execute (CopyFeatures).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried searching the various solutions here and elsewhere, but largely they don't apply? Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:21:24 GMT</pubDate>
    <dc:creator>MichaelRiccio1</dc:creator>
    <dc:date>2021-12-12T02:21:24Z</dc:date>
    <item>
      <title>Script won't run outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616511#M48108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am fairly new to Python, but I'm having an issue running a script. It runs fine when I use the python window in ArcMap, but when I try to run the same script either from double clicking a .py file, or running in the IDLE window, I get an error. I know I can easily do this just using select by attributes in ArcMap, but I'm trying to learn more python to automate more things down the road, this is a first test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

tree = r"M:\\Temp\ArcPy\Tree.shp"
arcpy.env.overwriteOutput=True 
arcpy.MakeFeatureLayer_management(tree, "Tree")
arcpy.SelectLayerByAttribute_management("Tree","NEW_SELECTION",' "Diameter" &amp;gt;=50')
arcpy.CopyFeatures_management ("Tree","Trees50DBH")
arcpy.FeatureClassToFeatureClass_conversion("TreesGreater50DBH",r"M:\\Temp\ArcPy","Tree50DBH")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Error (happens at the arcpy.CopyFeatures_management code)&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "M:\Temp\ArcPY\TreeArcPyTest.py", line 12, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management ("Tree","Trees50DBH")&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 2434, in CopyFeatures&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000210: Cannot create output Trees50DBH&lt;/P&gt;&lt;P&gt;Failed to execute (CopyFeatures).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried searching the various solutions here and elsewhere, but largely they don't apply? Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:21:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616511#M48108</guid>
      <dc:creator>MichaelRiccio1</dc:creator>
      <dc:date>2021-12-12T02:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't run outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616512#M48109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can start by putting an "r" before you path assignment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14478655135666850 jive_text_macro" data-renderedposition="50_8_912_16" jivemacro_uid="_14478655135666850"&gt;&lt;P&gt;tree = r"M:\\Temp\ArcPy\Tree.shp"&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also, check out &lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;​&amp;nbsp; for info on posting/formatting your code.&amp;nbsp; Makes it easier for others to read, and helps with knowing if you space/tabs are lined up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 16:53:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616512#M48109</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-11-18T16:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't run outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616513#M48110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm guessing your problem is with workspaces. In the call to the CopyFeatures tool you're specifying the name of the output class without the directory. Try giving the following a shot. I'm assuming you want to create shapefiles, so I added the extension to the name of the output file. I'd assume in arcmap that everything would output to the default.gdb.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os


tree = r"M:\Temp\ArcPy\Tree.shp"
arcpy.env.overwriteOutput = True
arcpy.env.workspace = os.path.dirname(tree)
arcpy.management.MakeFeatureLayer_management(tree, "Tree")
arcpy.SelectLayerByAttribute_management("Tree","NEW_SELECTION",'"Diameter" &amp;gt;=50')
arcpy.CopyFeatures_management ("Tree","Trees50DBH.shp")
arcpy.FeatureClassToFeatureClass_conversion("TreesGreater50DBH", r"M:\Temp\ArcPy","Tree50DBH.shp")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:21:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616513#M48110</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2021-12-12T02:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't run outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616514#M48111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the formatting tip. I have updated the post. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also added the r in front of the path assignment, but result is unchanged. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 17:06:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616514#M48111</guid>
      <dc:creator>MichaelRiccio1</dc:creator>
      <dc:date>2015-11-18T17:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script won't run outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616515#M48112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, this has made it work. In the future I'll keep the workspace issue in mind and add any file extensions. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 17:12:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-won-t-run-outside-of-arcmap/m-p/616515#M48112</guid>
      <dc:creator>MichaelRiccio1</dc:creator>
      <dc:date>2015-11-18T17:12:27Z</dc:date>
    </item>
  </channel>
</rss>

