Using Third Party Modules within ArcToolbox Script

620
2
03-24-2017 11:03 AM
BenjaminMittler
Occasional Contributor III

Hi all and thanks in advanced. 

Im working on creating a python tool that will be placed in a tooblox on a network drive within my organization. The tool needs to use the xlutils module but our organization does not have the module installed on our computers. I know that if you place the module in the same folder as the scripting tool .py file you should be able to import. I set up my toolbox and placed the module in the same folder as the toolbox / script. 

When I run the script from IDE everything runs fine. However, running the tool from within ArcMap yields the error:

AttributeError: 'module' object has no attribute 'copy'

Anyone have no tips? 

*Self taught python so sorry if i have the wrong terminology. 

Tags (1)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

what are you using from that module?  copy?  My preference is to import the module then use module.function method of using imports (ie xutils.copy.... ) if that is indeed the function.  This ensures that namespace doesn't get overwritten/redefined

BenjaminMittler
Occasional Contributor III

Yes I am using copy from the module. For some reason importing the module then using xlutils.copy wasnt working. However, Importing as "from xlutils import copy" seemed to solve the issue. Weird because I could have sworn that was one of the first things I tried. 

Thanks!

Ben

0 Kudos