I am creating an arcmap add-in which relies on a third party module, usaddress. I am using pip to install the usaddress module on the user's computer. When I run the add in however, it says that usaddress was successfully installed but then fails to import the usaddress module with "No module named usaddress". Once I close arcmap and all python scripts, it then imports the module for some computers. Other computers I have tested, it still doesn't install the module at all. But when I run the code independent of the add-in, it successfully installs the module. This is not ideal as I can't do it on every user's machine.
Any ideas as to why this is happening?
See the relevant code below:
import pip
import arcpy
required_pkgs=["usaddress"]
installed_pkgs=[pkg.key for pkg in pip.get_installed_distributions()]
for package in required_pkgs:
if package not in installed_pkgs:
arcpy.AddMessage("Installing {0}..................".format(package))
pip.main(['install',package])
arcpy.AddMessage("Succcessfully installed {0}..................".format(package))
else:
arcpy.AddMessage("Upgrading {0}..................".format(package))
pip.main(['install',"--upgrade", package])
import usaddress