ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
246 stars 327 forks source link

ModuleNotFoundError: No module named 'azure.mgmt.managementgroups' #644

Closed nicolaibaralmueller closed 2 years ago

nicolaibaralmueller commented 2 years ago
SUMMARY

Installing requirements-azure.txt shows incompatible requirements.

Although latest requirements get installed the ansible module still shows the error ModuleNotFoundError: No module named 'azure.mgmt.managementgroups'.

ISSUE TYPE
COMPONENT NAME

azure.azcollection.azure_rm_virtualmachine_info

ANSIBLE VERSION
ansible 2.9.16
  config file = None
  configured module search path = ['/home/nbm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
COLLECTION VERSION
1.9.0
OS / ENVIRONMENT

Ubuntu 20.04

STEPS TO REPRODUCE
azure.azcollection.azure_rm_virtualmachine_info:
    tenant: '{{ tenant }}'
    client_id: '{{ client_id }}'
    secret: '{{ secret }}'
    subscription_id: '{{ subscription_id }}'
    tags:
      - type:{{ tag }}
pip3 install -r requirements-azure.txt1 --force
ERROR: msal 1.0.0 has requirement PyJWT[crypto]<2,>=1.0.0, but you'll have pyjwt 2.1.0 which is incompatible.
ERROR: azure-mgmt-datalake-nspkg 3.0.1 has requirement azure-mgmt-nspkg>=3.0.0, but you'll have azure-mgmt-nspkg 2.0.0 which is incompatible.
ACTUAL RESULTS

Changed zure-mgmt-nspkg==2.0.0 and azure-nspkg==2.0.0 to version 3.0.1. Added PyJWT to version 1.7.1 in azure-requirements.txt and installation is succesful without errors.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'azure.mgmt.managementgroups'
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on ubuntu's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
nicolaibaralmueller commented 2 years ago

This was solved by creating a virtual python environment and setting the correct python interpreter in ansible.

https://www.redhat.com/sysadmin/python-venv-ansible

Fred-sun commented 2 years ago

@nicolaibaralmueller Thank you for submitting this issue, as you can see from the log you submitted, it is the dependency that did not install successfully. You are advised to uninstall and reinstall. Thank you very much! ···e.g. pip3 install -r requirements-azure.txt

alfador1 commented 2 years ago

I'm facing the same issue. Did u fix it and how ?

Fred-sun commented 2 years ago

@alfador1 This issue has been addressed in the new virtual environment. It is recommended that you install the Ansible-Collection dependency package (requirement.txt) in a python interpreter working environment. If you have any questions, we welcome your questions. Thank you very much!

nicolaibaralmueller commented 2 years ago

I'm facing the same issue. Did u fix it and how ?

I now use virtual python environments. Guide further above.

This is my requirement file:

packaging
requests[security]
xmltodict
azure-cli-core==2.11.1
azure-common==1.1.11
azure-mgmt-apimanagement==0.2.0
azure-mgmt-authorization==0.51.1
azure-mgmt-batch==5.0.1
azure-mgmt-cdn==3.0.0
azure-mgmt-compute==10.0.0
azure-mgmt-containerinstance==1.4.0
azure-mgmt-containerregistry==2.0.0
azure-mgmt-containerservice==9.1.0
azure-mgmt-datalake-store==0.5.0
azure-mgmt-dns==2.1.0
azure-mgmt-keyvault==1.1.0
azure-mgmt-marketplaceordering==0.1.0
azure-mgmt-monitor==0.5.2
azure-mgmt-managedservices==1.0.0
azure-mgmt-managementgroups==0.2.0
azure-mgmt-network==12.0.0
azure-mgmt-nspkg==3.0.1
azure-mgmt-privatedns==0.1.0
azure-mgmt-redis==5.0.0
azure-mgmt-resource==10.2.0
azure-mgmt-rdbms==1.9.0
azure-mgmt-search==3.0.0
azure-mgmt-servicebus==0.5.3
azure-mgmt-sql==0.10.0
azure-mgmt-storage==11.1.0
azure-mgmt-trafficmanager==0.50.0
azure-mgmt-web==0.41.0
PyJWT==1.7.1
azure-nspkg==3.0.1
azure-storage==0.35.1
msrest==0.6.21
msrestazure==0.6.4
azure-keyvault==1.0.0a1
azure-graphrbac==0.61.1
azure-mgmt-cosmosdb==0.5.2
azure-mgmt-hdinsight==0.1.0
azure-mgmt-devtestlabs==3.0.0
azure-mgmt-loganalytics==1.0.0
azure-mgmt-automation==0.1.1
azure-mgmt-iothub==0.7.0
azure-mgmt-recoveryservices==0.4.0
azure-mgmt-recoveryservicesbackup==0.6.0
azure-mgmt-notificationhubs==2.0.0
azure-mgmt-eventhub==2.0.0
pywinrm>=0.3.0
kubernetes
alfador1 commented 2 years ago

I tried this but is not working for me

nicolaibaralmueller commented 2 years ago

I tried this but is not working for me

Create a python virtual environment. Activate the environment and install the requirements. That should work.

alfador1 commented 2 years ago

I just did that but still getting the same error

alfador1 commented 2 years ago
(ansible2.10) [root@1e83e0256499 python-venv]# python --version
Python 3.6.8
(ansible2.10) [root@1e83e0256499 python-venv]# ansible --version
ansible 2.10.15
  config file = None
  configured module search path = ['/root/python-venv/plugins/modules', '/ansible/library']
  ansible python module location = /root/python-venv/ansible2.10/lib64/python3.6/site-packages/ansible
  executable location = /root/python-venv/ansible2.10/bin/ansible
  python version = 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
(ansible2.10) [root@1e83e0256499 python-venv]# ansible-galaxy collection list

# /root/python-venv/ansible2.10/lib/python3.6/site-packages/ansible_collections
Collection                Version
------------------------- -------
amazon.aws                1.2.0
ansible.netcommon         1.2.1
ansible.posix             1.1.1
ansible.windows           1.0.0
arista.eos                1.0.3
awx.awx                   14.1.0
azure.azcollection        1.10.0
check_point.mgmt          1.0.6
chocolatey.chocolatey     1.0.2
cisco.aci                 1.0.0
cisco.asa                 1.0.3
cisco.intersight          1.0.8
cisco.ios                 1.0.3
cisco.iosxr               1.0.5
cisco.meraki              2.0.0
cisco.mso                 1.0.0
cisco.nxos                1.1.0
cisco.ucs                 1.5.0
cloudscale_ch.cloud       1.1.0
community.aws             1.2.0
community.azure           1.0.0
community.crypto          1.1.1
community.digitalocean    1.0.0
community.general         1.1.0
community.grafana         1.0.0
community.kubernetes      1.0.0
community.libvirt         1.0.0
community.mongodb         1.0.0
community.mysql           1.0.0
community.network         1.1.0
community.proxysql        1.0.0
community.rabbitmq        1.0.1
community.skydive         1.0.0
community.vmware          1.2.0
community.windows         1.0.0
community.zabbix          1.0.0
containers.podman         1.2.0
cyberark.conjur           1.0.7
cyberark.pas              1.0.5
dellemc.os10              1.0.1
dellemc.os6               1.0.2
dellemc.os9               1.0.2
f5networks.f5_modules     1.5.0
fortinet.fortimanager     1.0.5
fortinet.fortios          1.0.15
frr.frr                   1.0.3
gluster.gluster           1.0.1
google.cloud              1.0.0
hetzner.hcloud            1.0.0
ibm.qradar                1.0.3
infinidat.infinibox       1.2.3
junipernetworks.junos     1.1.0
mellanox.onyx             1.0.0
netapp.aws                20.8.0
netapp.elementsw          20.8.0
netapp.ontap              20.8.0
netapp_eseries.santricity 1.0.8
netbox.netbox             1.0.2
ngine_io.cloudstack       1.0.1
ngine_io.exoscale         1.0.0
ngine_io.vultr            1.0.0
openstack.cloud           1.1.0
openvswitch.openvswitch   1.0.5
ovirt.ovirt               1.1.3
purestorage.flasharray    1.4.0
purestorage.flashblade    1.3.0
servicenow.servicenow     1.0.2
splunk.es                 1.0.2
theforeman.foreman        1.1.0
vyos.vyos                 1.0.4
wti.remote                1.0.1

# /root/python-venv/ansible2.10/lib64/python3.6/site-packages/ansible_collections
Collection                Version
------------------------- -------
amazon.aws                1.2.0
ansible.netcommon         1.2.1
ansible.posix             1.1.1
ansible.windows           1.0.0
arista.eos                1.0.3
awx.awx                   14.1.0
azure.azcollection        1.10.0
check_point.mgmt          1.0.6
chocolatey.chocolatey     1.0.2
cisco.aci                 1.0.0
cisco.asa                 1.0.3
cisco.intersight          1.0.8
cisco.ios                 1.0.3
cisco.iosxr               1.0.5
cisco.meraki              2.0.0
cisco.mso                 1.0.0
cisco.nxos                1.1.0
cisco.ucs                 1.5.0
cloudscale_ch.cloud       1.1.0
community.aws             1.2.0
community.azure           1.0.0
community.crypto          1.1.1
community.digitalocean    1.0.0
community.general         1.1.0
community.grafana         1.0.0
community.kubernetes      1.0.0
community.libvirt         1.0.0
community.mongodb         1.0.0
community.mysql           1.0.0
community.network         1.1.0
community.proxysql        1.0.0
community.rabbitmq        1.0.1
community.skydive         1.0.0
community.vmware          1.2.0
community.windows         1.0.0
community.zabbix          1.0.0
containers.podman         1.2.0
cyberark.conjur           1.0.7
cyberark.pas              1.0.5
dellemc.os10              1.0.1
dellemc.os6               1.0.2
dellemc.os9               1.0.2
f5networks.f5_modules     1.5.0
fortinet.fortimanager     1.0.5
fortinet.fortios          1.0.15
frr.frr                   1.0.3
gluster.gluster           1.0.1
google.cloud              1.0.0
hetzner.hcloud            1.0.0
ibm.qradar                1.0.3
infinidat.infinibox       1.2.3
junipernetworks.junos     1.1.0
mellanox.onyx             1.0.0
netapp.aws                20.8.0
netapp.elementsw          20.8.0
netapp.ontap              20.8.0
netapp_eseries.santricity 1.0.8
netbox.netbox             1.0.2
ngine_io.cloudstack       1.0.1
ngine_io.exoscale         1.0.0
ngine_io.vultr            1.0.0
openstack.cloud           1.1.0
openvswitch.openvswitch   1.0.5
ovirt.ovirt               1.1.3
purestorage.flasharray    1.4.0
purestorage.flashblade    1.3.0
servicenow.servicenow     1.0.2
splunk.es                 1.0.2
theforeman.foreman        1.1.0
vyos.vyos                 1.0.4
wti.remote                1.0.1

# /root/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.10.0
(ansible2.10) [root@1e83e0256499 python-venv]# ^C
(ansible2.10) [root@1e83e0256499 python-venv]# pip list
Package                           Version
--------------------------------- ---------
adal                              1.2.7
ansible                           2.10.0
ansible-base                      2.10.15
applicationinsights               0.11.10
argcomplete                       1.12.3
azure-cli-core                    2.11.1
azure-cli-telemetry               1.0.6
azure-common                      1.1.11
azure-core                        1.20.1
azure-graphrbac                   0.61.1
azure-identity                    1.7.0
azure-keyvault                    1.0.0a1
azure-mgmt-apimanagement          0.2.0
azure-mgmt-authorization          0.51.1
azure-mgmt-automation             0.1.1
azure-mgmt-batch                  5.0.1
azure-mgmt-cdn                    3.0.0
azure-mgmt-compute                10.0.0
azure-mgmt-containerinstance      1.4.0
azure-mgmt-containerregistry      2.0.0
azure-mgmt-containerservice       9.1.0
azure-mgmt-core                   1.2.0
azure-mgmt-cosmosdb               0.5.2
azure-mgmt-datalake-nspkg         2.0.0
azure-mgmt-datalake-store         0.5.0
azure-mgmt-devtestlabs            3.0.0
azure-mgmt-dns                    2.1.0
azure-mgmt-eventhub               2.0.0
azure-mgmt-hdinsight              0.1.0
azure-mgmt-iothub                 0.7.0
azure-mgmt-keyvault               1.1.0
azure-mgmt-loganalytics           1.0.0
azure-mgmt-managedservices        1.0.0
azure-mgmt-managementgroups       0.2.0
azure-mgmt-marketplaceordering    0.1.0
azure-mgmt-monitor                0.5.2
azure-mgmt-network                12.0.0
azure-mgmt-notificationhubs       2.0.0
azure-mgmt-nspkg                  3.0.1
azure-mgmt-privatedns             0.1.0
azure-mgmt-rdbms                  1.9.0
azure-mgmt-recoveryservices       0.4.0
azure-mgmt-recoveryservicesbackup 0.6.0
azure-mgmt-redis                  5.0.0
azure-mgmt-resource               10.2.0
azure-mgmt-search                 3.0.0
azure-mgmt-servicebus             0.5.3
azure-mgmt-sql                    0.10.0
azure-mgmt-storage                11.1.0
azure-mgmt-trafficmanager         0.50.0
azure-mgmt-web                    0.41.0
azure-nspkg                       3.0.1
azure-storage                     0.35.1
bcrypt                            3.2.0
cachetools                        4.2.4
certifi                           2021.10.8
cffi                              1.15.0
chardet                           4.0.0
charset-normalizer                2.0.8
colorama                          0.4.4
cryptography                      3.3.2
dnspython                         2.1.0
google-auth                       2.3.3
humanfriendly                     8.2
idna                              2.10
importlib-metadata                4.8.2
isodate                           0.6.0
Jinja2                            3.0.3
jmespath                          0.10.0
knack                             0.7.2
kubernetes                        19.15.0
lxml                              4.6.3
MarkupSafe                        2.0.1
msal                              1.0.0
msal-extensions                   0.1.3
msrest                            0.6.21
msrestazure                       0.6.4
ntlm-auth                         1.5.0
oauthlib                          3.1.1
packaging                         21.3
paramiko                          2.8.0
pip                               21.3.1
pkginfo                           1.8.1
portalocker                       1.7.1
psutil                            5.8.0
pyasn1                            0.4.8
pyasn1-modules                    0.2.8
pycparser                         2.21
Pygments                          2.10.0
PyJWT                             1.7.1
PyNaCl                            1.4.0
pyOpenSSL                         21.0.0
pyparsing                         3.0.6
python-dateutil                   2.8.2
pywinrm                           0.4.2
PyYAML                            6.0
requests                          2.26.0
requests-ntlm                     1.1.0
requests-oauthlib                 1.3.0
resolvelib                        0.5.4
rsa                               4.8
setuptools                        59.2.0
six                               1.16.0
tabulate                          0.8.9
typing_extensions                 4.0.0
urllib3                           1.26.7
websocket-client                  1.2.1
xmltodict                         0.12.0
zipp                              3.6.0
nicolaibaralmueller commented 2 years ago

I just did that but still getting the same error

Did you set the python interpreter?

Add below line to ansible.cfg.

interpreter_python = /home/username/python/ansible3.0/bin/python