Azure: faq - ansible/community GitHub Wiki
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.
-
The libraries is installed by pip3 and under python 3.XXXX folder, but ansible uses python 2 to load libraries.
-
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. -
There are many libraries named
azure.mgmt...., they maybe installed in different folders. E.G.azure.mgmt.webis under/usr/lib/..., whileazure.mgmt.computeis under~/.username/lib.... When python try to importazure.mgmt.compute, it first imports the azure package. Unfortunately, your python find azure under/usr/libforazure.mgmt.web, it searchesmgmt.computeunder this folder, failed and throw such exception. Here we need to move them into one directory.
-
Check your packages is already installed, check whether the missing package is in the returned list.
pip freeze
-
Check whether the package path is in the PYTHONPATH:
-
check your python sys path:
python -c "import sys; print(sys.path)" -
find your target package path
sudo find / | grep '<your missing package name>'
-
check the step2's path is in the setp1's sys path. If not, add the
PYTHONPATHbyexport PYTHONPATH=PYTHONPATH:<path found in previous step>
-
-
Your
azure.mgmt.XXXis installed in different path from other azure mgmt packages.-
find the
azure/mgmt/webpath bysudo find / | grep "azure/mgmt/web", and note it asweb_path -
enter python bash by typing
python -
find azure path by the following python script and not the
azure.__file__path asazure_path.import azure; azure.__file__; exit()
-
copy the
azure-mgmt-webpackage to the azure directory bysudo cp -rf <web-path>/azure/* <azure-path>/
-