<?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 How to debug arcpy code in visual studio 2019 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1057858#M61117</link>
    <description>&lt;LI-CODE lang="python"&gt;# This script clips all feature classes in a file geodatabase

import arcpy

# Create path variables
sourceWorkspace = r"C:\Users\Lesson2Practice\USA.gdb"
targetWorkspace = r"C:\Users\Lesson2Practice\Iowa.gdb"
clipfeature = r"C:\Users\Lesson2Practice\Iowa.gdb\Iowa"

# Get a list of all feature classes in the USA geodatabase
arcpy.env.workspace = sourceWorkspace
featureClassList = arcpy.ListFeatureClasses()

try:
    # Loop through all USA faeture classes
    for featureClass in featureClassList:
        
        # Construct the output path
        outClipFeatureClass = f'{targetWorkspace}\Iowa{featureClass}'

        # Perform Clip
        arcpy.Clip_analysis(featureClass,clipfeature,outClipFeatureClass)
        arcpy.AddMessage(f'Wrote clipped file {outClipFeatureClass}.')
        print(f"Wrote clipped file {outClipFeatureClass}.")
except:
    # Report if there was an error
    arcpy.AddError("Could not clip feature classes")
    print("Could not clip feature classses")
    print(arcpy.GetMessages())&lt;/LI-CODE&gt;&lt;P&gt;I have created a python script file that I am debugging it using visual studio 2019, But as soon as I try to debug, it gives me and Exception on another file (&lt;STRONG&gt;time.py&lt;/STRONG&gt; - not sure where it came from as this &lt;STRONG&gt;time.py&lt;/STRONG&gt; is not in my project or folder) stating &lt;STRONG&gt;"name 'm' is not defined"&lt;/STRONG&gt; (I am attaching a video of the exception). Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6254099318001w990h540r211" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6254099318001" data-account="6161463677001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6161463677001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6254099318001w990h540r211');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.esri.com/t5/video/gallerypage/video-id/6254099318001"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 May 2021 21:46:30 GMT</pubDate>
    <dc:creator>ManishShrivastav</dc:creator>
    <dc:date>2021-05-13T21:46:30Z</dc:date>
    <item>
      <title>How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1057858#M61117</link>
      <description>&lt;LI-CODE lang="python"&gt;# This script clips all feature classes in a file geodatabase

import arcpy

# Create path variables
sourceWorkspace = r"C:\Users\Lesson2Practice\USA.gdb"
targetWorkspace = r"C:\Users\Lesson2Practice\Iowa.gdb"
clipfeature = r"C:\Users\Lesson2Practice\Iowa.gdb\Iowa"

# Get a list of all feature classes in the USA geodatabase
arcpy.env.workspace = sourceWorkspace
featureClassList = arcpy.ListFeatureClasses()

try:
    # Loop through all USA faeture classes
    for featureClass in featureClassList:
        
        # Construct the output path
        outClipFeatureClass = f'{targetWorkspace}\Iowa{featureClass}'

        # Perform Clip
        arcpy.Clip_analysis(featureClass,clipfeature,outClipFeatureClass)
        arcpy.AddMessage(f'Wrote clipped file {outClipFeatureClass}.')
        print(f"Wrote clipped file {outClipFeatureClass}.")
except:
    # Report if there was an error
    arcpy.AddError("Could not clip feature classes")
    print("Could not clip feature classses")
    print(arcpy.GetMessages())&lt;/LI-CODE&gt;&lt;P&gt;I have created a python script file that I am debugging it using visual studio 2019, But as soon as I try to debug, it gives me and Exception on another file (&lt;STRONG&gt;time.py&lt;/STRONG&gt; - not sure where it came from as this &lt;STRONG&gt;time.py&lt;/STRONG&gt; is not in my project or folder) stating &lt;STRONG&gt;"name 'm' is not defined"&lt;/STRONG&gt; (I am attaching a video of the exception). Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6254099318001w990h540r971" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6254099318001" data-account="6161463677001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6161463677001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6254099318001w990h540r971');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.esri.com/t5/video/gallerypage/video-id/6254099318001"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 21:46:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1057858#M61117</guid>
      <dc:creator>ManishShrivastav</dc:creator>
      <dc:date>2021-05-13T21:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1060307#M61184</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Have you solved issue with&amp;nbsp;&lt;STRONG&gt;"name 'm' is not defined"&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;I have the same situation as you&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 08:31:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1060307#M61184</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-05-21T08:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1060441#M61192</link>
      <description>&lt;P&gt;I am still waiting for it.&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 14:58:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1060441#M61192</guid>
      <dc:creator>ManishShrivastav</dc:creator>
      <dc:date>2021-05-21T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1080016#M61802</link>
      <description>&lt;P&gt;I have the same issue. It looks like when I import arcpy in Visual Studio, it loads 'arcpy.time', and it doesn't matter if I use any datetime functions in my code but the debug detects the name error.&lt;/P&gt;&lt;P&gt;I opened the time.py file and in line 267, there is a variable m&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;del m&lt;BR /&gt;except NameError:&lt;BR /&gt;pass&lt;/P&gt;&lt;P&gt;I cannot modify this time.py file since it's part of arcpy package. Don't know how to solve this problem.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 17:44:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1080016#M61802</guid>
      <dc:creator>ChenChen4</dc:creator>
      <dc:date>2021-07-17T17:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1103711#M62570</link>
      <description>&lt;P&gt;Did anyone Get any help on this? I have the same issue as the rest of you. ChenChen4 is exactly where I got.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 20:02:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1103711#M62570</guid>
      <dc:creator>RobbCampbell</dc:creator>
      <dc:date>2021-09-30T20:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1122026#M63117</link>
      <description>&lt;P&gt;I'm running into this same message too when adding "import arcpy"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ArcPy Debugging.png" style="width: 629px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/28667i560D2A5A6977F033/image-size/large?v=v2&amp;amp;px=999" role="button" title="ArcPy Debugging.png" alt="ArcPy Debugging.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It's annoying but is this actually a problem? I notice you can just click "Continue" on the visual studio toolbar and the rest of my project runs fine.&lt;/P&gt;&lt;P&gt;Also, if I choose to "Debug"-&amp;gt; "Execute Project in Python Interactive" there's no error at all.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 02:00:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1122026#M63117</guid>
      <dc:creator>BrynR</dc:creator>
      <dc:date>2021-12-02T02:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1123252#M63160</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;When you&amp;nbsp; wrote "&lt;SPAN&gt;if I choose to "Debug"-&amp;gt; "Execute Project in Python Interactive" there's no error at all.", do you mean running script with $load command?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For me it stops with other things like:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dirname = os.path.dirname(__file__)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 07:23:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1123252#M63160</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-12-07T07:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1123523#M63163</link>
      <description>&lt;P&gt;No, I mean the the option from the Debug menu. Shortcut key Shift+Alt+F5&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29038iF417979D0E309EAB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 19:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1123523#M63163</guid>
      <dc:creator>BrynR</dc:creator>
      <dc:date>2021-12-07T19:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug arcpy code in visual studio 2019</title>
      <link>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1182184#M64754</link>
      <description>&lt;P&gt;Did anyone ever solve this?&lt;/P&gt;&lt;P&gt;I am trying to debug a project in VS using the arcgispro-py3 environment.&amp;nbsp; This error happens when you reference python's datetime.datetime class after the arcpy site package is loaded.&lt;/P&gt;&lt;P&gt;The project works when run in the python interactive window, but throws the same error when using Debug in VS.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 01:32:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-debug-arcpy-code-in-visual-studio-2019/m-p/1182184#M64754</guid>
      <dc:creator>ACrateau</dc:creator>
      <dc:date>2022-06-13T01:32:53Z</dc:date>
    </item>
  </channel>
</rss>

