{"id":183461,"date":"2012-12-14T22:41:50","date_gmt":"2012-12-14T22:41:50","guid":{"rendered":"http:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=183461"},"modified":"2018-12-18T11:22:33","modified_gmt":"2018-12-18T19:22:33","slug":"how-to-debug-python-toolboxes-in-3-easy-steps","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps","title":{"rendered":"How to Debug Python Toolboxes in 3 Easy Steps"},"author":5121,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[37501,23341],"tags":[72381,24341],"industry":[],"product":[36991],"class_list":["post-183461","blog","type-blog","status-publish","format-standard","hentry","category-administration","category-analytics","tag-debugging","tag-python","product-arcgis-desktop"],"acf":{"short_description":"This blog demonstrates how you can debug a Python Toolbox (.pyt) to troubleshoot and fix any errors that may be causing your tool to fail","flexible_content":[{"acf_fc_layout":"content","content":"<p>This blog demonstrates how you can debug a Python Toolbox (.pyt) to troubleshoot and fix any errors that may be causing your tool to fail or produce invalid results.<\/p>\n<p><a href=\"http:\/\/resources.arcgis.com\/en\/help\/main\/10.1\/index.html#\/\/001500000022000000\">Python Toolboxes<\/a>\u00a0are new at ArcGIS 10.1 and provide a new way to create geoprocessing tools entirely in Python with no requirement to use ArcGIS for Desktop.<span id=\"more-24049\"><\/span><\/p>\n<p>The following screen capture illustrates three things you must do to start debugging your Python Toolbox. For\u00a0clarity, some methods have been collapsed and documentation strings are removed.<\/p>\n<ol>\n<li>\u00a0Add a\u00a0<em>main()<\/em>\u00a0function. Within this function, create an instance of the tool class and call it\u2019s\u00a0<em>execute()<\/em>\u00a0method. The arguments for\u00a0<em>execute()<\/em>include the parameter information created by the\u00a0<em>getParameterInfo()<\/em>\u00a0method and the messages which are set to None.<\/li>\n<li>Comment out existing lines for retrieving parameter values, and enter hard-coded parameter values.<\/li>\n<li>Set a break point at the position where you want to start stepping through the code.<\/li>\n<\/ol>\n<p><a href=\"http:\/\/blogs.esri.com\/esri\/arcgis\/files\/2012\/12\/PYTDebugging.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-24050 aligncenter\" src=\"http:\/\/blogs.esri.com\/esri\/arcgis\/files\/2012\/12\/PYTDebugging-254x300.png\" alt=\"\" width=\"254\" height=\"300\" \/><\/a><\/p>\n<p>That\u2019s it! \u00a0In three simple steps, you can begin debugging and troubleshooting any problems with your Python Toolbox. After the problems are fixed, remove the parameter values you entered, as well as, the<em>\u00a0main()<\/em>\u00a0function.<\/p>\n<p><strong>USAGE TIP:<\/strong><\/p>\n<p>A Python Toolbox is an ASCII-based file with a .pyt extension. By default, Python IDE\u2019s do not recognize this extension as a Python file type. Fortunately, most IDE\u2019s have an option where you can change the syntax to Python. Here are the steps to do this in PyScripter and Wing IDE.<\/p>\n<p>PyScripter \u2013 Go to the View menu, Syntax and select Python.<\/p>\n<p><a href=\"http:\/\/blogs.esri.com\/esri\/arcgis\/files\/2012\/12\/PyScripter_PythonSyntax1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-24052\" src=\"http:\/\/blogs.esri.com\/esri\/arcgis\/files\/2012\/12\/PyScripter_PythonSyntax1-268x300.png\" alt=\"\" width=\"268\" height=\"300\" \/><\/a><\/p>\n<p>Wing IDE \u2013 Go to the Source menu, Current File Properties\u2026 and select the File Type to be Python.<\/p>\n<p><a href=\"http:\/\/blogs.esri.com\/esri\/arcgis\/files\/2012\/12\/Wing_PythonSyntax.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-24053\" src=\"http:\/\/blogs.esri.com\/esri\/arcgis\/files\/2012\/12\/Wing_PythonSyntax-298x300.png\" alt=\"\" width=\"298\" height=\"300\" \/><\/a><\/p>\n"}],"authors":[{"ID":5121,"user_firstname":"","user_lastname":"","nickname":"jpardy84","user_nicename":"jpardy84","display_name":"jpardy","user_email":"jpardy@esri.com","user_url":"","user_registered":"2018-03-02 00:16:49","user_description":"","user_avatar":"<img alt='' src='https:\/\/secure.gravatar.com\/avatar\/ef5394b9654988f205fc1c43beebaef1eea90faf08e750f1b4d89434fc733f9b?s=96&#038;d=blank&#038;r=g' srcset='https:\/\/secure.gravatar.com\/avatar\/ef5394b9654988f205fc1c43beebaef1eea90faf08e750f1b4d89434fc733f9b?s=192&#038;d=blank&#038;r=g 2x' class='avatar avatar-96 photo' height='96' width='96' loading='lazy' decoding='async'\/>"}],"related_articles":"","card_image":false,"wide_image":false},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Debug Python Toolboxes in 3 Easy Steps<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Debug Python Toolboxes in 3 Easy Steps\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-18T19:22:33+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\"},\"author\":{\"name\":\"jpardy\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/424b923d0991fee8d20fd49f9912af94\"},\"headline\":\"How to Debug Python Toolboxes in 3 Easy Steps\",\"datePublished\":\"2012-12-14T22:41:50+00:00\",\"dateModified\":\"2018-12-18T19:22:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\"},\"wordCount\":8,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"debugging\",\"python\"],\"articleSection\":[\"Administration\",\"Analytics\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\",\"name\":\"How to Debug Python Toolboxes in 3 Easy Steps\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2012-12-14T22:41:50+00:00\",\"dateModified\":\"2018-12-18T19:22:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Debug Python Toolboxes in 3 Easy Steps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/424b923d0991fee8d20fd49f9912af94\",\"name\":\"jpardy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ef5394b9654988f205fc1c43beebaef1eea90faf08e750f1b4d89434fc733f9b?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ef5394b9654988f205fc1c43beebaef1eea90faf08e750f1b4d89434fc733f9b?s=96&d=blank&r=g\",\"caption\":\"jpardy\"},\"url\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Debug Python Toolboxes in 3 Easy Steps","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps","og_locale":"en_US","og_type":"article","og_title":"How to Debug Python Toolboxes in 3 Easy Steps","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2018-12-18T19:22:33+00:00","twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps"},"author":{"name":"jpardy","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/424b923d0991fee8d20fd49f9912af94"},"headline":"How to Debug Python Toolboxes in 3 Easy Steps","datePublished":"2012-12-14T22:41:50+00:00","dateModified":"2018-12-18T19:22:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps"},"wordCount":8,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["debugging","python"],"articleSection":["Administration","Analytics"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps","name":"How to Debug Python Toolboxes in 3 Easy Steps","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2012-12-14T22:41:50+00:00","dateModified":"2018-12-18T19:22:33+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/how-to-debug-python-toolboxes-in-3-easy-steps#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"How to Debug Python Toolboxes in 3 Easy Steps"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/424b923d0991fee8d20fd49f9912af94","name":"jpardy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ef5394b9654988f205fc1c43beebaef1eea90faf08e750f1b4d89434fc733f9b?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef5394b9654988f205fc1c43beebaef1eea90faf08e750f1b4d89434fc733f9b?s=96&d=blank&r=g","caption":"jpardy"},"url":""}]}},"text_date":"December 14, 2012","author_name":"jpardy","author_page":false,"custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2025\/08\/Newsroom-Keyart-Wide-1920-x-1080.jpg","primary_product":"ArcMap","tag_data":[{"term_id":72381,"name":"debugging","slug":"debugging","term_group":0,"term_taxonomy_id":72381,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"},{"term_id":24341,"name":"python","slug":"python","term_group":0,"term_taxonomy_id":24341,"taxonomy":"post_tag","description":"","parent":0,"count":171,"filter":"raw"}],"category_data":[{"term_id":37501,"name":"Administration","slug":"administration","term_group":0,"term_taxonomy_id":37501,"taxonomy":"category","description":"","parent":0,"count":423,"filter":"raw"},{"term_id":23341,"name":"Analytics","slug":"analytics","term_group":0,"term_taxonomy_id":23341,"taxonomy":"category","description":"","parent":0,"count":1327,"filter":"raw"}],"product_data":[{"term_id":36991,"name":"ArcMap","slug":"arcgis-desktop","term_group":0,"term_taxonomy_id":36991,"taxonomy":"product","description":"","parent":36981,"count":325,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=arcgis-desktop","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/183461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/5121"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=183461"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/183461\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=183461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=183461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=183461"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=183461"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=183461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}