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\foodSecurity_v1.py", line 5, in <module>
import pygal as pg
File "C:\Python27\ArcGIS10.5\lib\site-packages\pygal\__init__.py", line 28, in <module>
File "C:\Python27\ArcGIS10.5\lib\site-packages\pkg_resources\__init__.py", line 46, in <module>
from pkg_resources.extern import six
File "C:\Python27\ArcGIS10.5\lib\site-packages\pkg_resources\extern\__init__.py", 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 (&quot;Object has no Attribute&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?