Azure: faq - ansible/community GitHub Wiki

Problem description

When running ansible or ansible-playbook with azure modules, youm may meet error message "Do you have azure>=2.0.0 installed? No module named XXXX".

Actually you have already installed the Azure SDK libraries when installing ansible[azure] modules.

Root cause

  1. The libraries is installed by pip3 and under python 3.XXXX folder, but ansible uses python 2 to load libraries.

  2. You install azure libraries into different pip library path. Some may be in the system path like /usr/lib/..., some may be under your profile folder like ~/.username/lib/.... One of the library path is not in your PYTHONPATH, the python interpreter failed to find the library.

  3. There are many libraries named azure.mgmt...., they maybe installed in different folders. E.G. azure.mgmt.web is under /usr/lib/..., while azure.mgmt.compute is under ~/.username/lib.... When python try to import azure.mgmt.compute, it first imports the azure package. Unfortunately, your python find azure under /usr/lib for azure.mgmt.web, it searches mgmt.compute under this folder, failed and throw such exception. Here we need to move them into one directory.

Solve solution

  1. Check your packages is already installed, check whether the missing package is in the returned list.

    pip freeze
  2. Check whether the package path is in the PYTHONPATH:

    1. check your python sys path:

      python -c "import sys; print(sys.path)"
    2. find your target package path

      sudo find / | grep '<your missing package name>'
    3. check the step2's path is in the setp1's sys path. If not, add the PYTHONPATH by

      export PYTHONPATH=PYTHONPATH:<path found in previous step>
  3. Your azure.mgmt.XXX is installed in different path from other azure mgmt packages.

    1. find the azure/mgmt/web path by sudo find / | grep "azure/mgmt/web", and note it as web_path

    2. enter python bash by typing python

    3. find azure path by the following python script and not the azure.__file__ path as azure_path.

      import azure;
      azure.__file__;
      exit()
    4. copy the azure-mgmt-web package to the azure directory by

      sudo cp -rf <web-path>/azure/* <azure-path>/
⚠️ **GitHub.com Fallback** ⚠️