-
Notifications
You must be signed in to change notification settings - Fork 3
1 FAQ: Do you have azure =2.0.0 installed? No module named XXX
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".
The cause may be one of the following:
-
Your installation dependency doesn't match the Ansible requirement.
-
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.web
is under/usr/lib/...
, whileazure.mgmt.compute
is under~/.username/lib...
. When python try to importazure.mgmt.compute
, it first imports the azure package. Unfortunately, your python find azure under/usr/lib
forazure.mgmt.web
, it searchesmgmt.compute
under 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
PYTHONPATH
byexport PYTHONPATH=PYTHONPATH:<path found in previous step>
-
-
Your
azure.mgmt.XXX
is installed in different path from other azure mgmt packages. Here useazure.mgmt.web
as an example, replaceweb
to your library.-
find the
azure/mgmt/web
path 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-web
package to the azure directory bysudo cp -rf <web-path>/azure/* <azure-path>/
-