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
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))
        arcpy.AddMessage("Succcessfully installed {0}..................".format(package))
        arcpy.AddMessage("Upgrading {0}..................".format(package))
        pip.main(['install',"--upgrade", package])
import usaddress
  • What happen when you try it without handling fails. Just "pip.main(['install',package])" .
    – BBG_GIS
    Dec 6, 2017 at 21:54
  • It still fails when I just use pip.main(['install',package])
    – ketar
    Dec 6, 2017 at 22:31
  • A complete stab in the dark here but I know one can reload() modules, could try that?
    – Hornbydd
    Dec 6, 2017 at 23:50
  • @Hornbydd I wouldn't be able to reload the usaddress module even before it's able to be imported. I am having issues with the import.
    – ketar
    Dec 7, 2017 at 19:20
  • Is each computer using the same version of ArcGIS and Python?
    – JCB
    Dec 19, 2017 at 20:17


Browse other questions tagged or ask your own question.