AnsweredAssumed Answered

'NoneType' Object has no Attribute 'modules' AttributeError the Second Time Script Tool is Run

Question asked by pamccord on Jun 15, 2018
Latest reply on Sep 13, 2018 by pamccord

I am developing a script tool that will be part of a suite of tools in an ArcToolbox. This script tool is intended to plot FAO food security indicators.

When I run this tool the first time from ArcToolbox (ie, I run the tool from ArcMap), it successfully completes without an issue (ie, the Pygal module (which I import) plots the food security indicator that the user selects for the country selected by the user). However, the second time that I run the tool, it fails with the following error:


Traceback (most recent call last):
File "C:\Users\Paul McCord\Google Drive\Toolbox\Tool_First\FoodSecurity\Content_Post052418\TestScripts\", line 5, in <module>
import pygal as pg
File "C:\Python27\ArcGIS10.5\lib\site-packages\pygal\", line 28, in <module>
import pkg_resources
File "C:\Python27\ArcGIS10.5\lib\site-packages\pkg_resources\", line 46, in <module>
from pkg_resources.extern import six
File "C:\Python27\ArcGIS10.5\lib\site-packages\pkg_resources\extern\", line 43, in load_module
mod = sys.modules[extant]
AttributeError: 'NoneType' object has no attribute 'modules'


Referring to a separate post that suggested removing the 'Try-Except' statement, I've tried removing this in order to resolve the issue, but it persists.

A similar GeoNet post exists (&amp;quot;Object has no Attribute&amp;quot;the second time through arcpy script ); however, in this post, the issue appears to arise from 'ImportToolbox.' I believe my issue arises from a module that I'm importing. Nevertheless, it does not appear that the issue was resolved in the earlier post.


Does anyone have experience with this issue while developing a Python script for a script tool?