Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Python venv - ImportError: No module named pyvcloud.vcd.org #207

Open
theovich opened this issue Feb 17, 2022 · 1 comment
Open

Python venv - ImportError: No module named pyvcloud.vcd.org #207

theovich opened this issue Feb 17, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@theovich
Copy link

Describe the bug

Hello,
I would like to run a module in python venv, but
for simple playbook I get this traceback even if pyvcloud is installed.
What can I do to make it work?

Thank you for your help.

----------------------------------
- name: "List catalog"
  hosts: localhost
  connection: local

  vars:
    vcd_org: organization
    vcd_vdc: VDC
    vcd_server: 10.23.33.81
    vcd_username: user
    vcd_password: pass
    vcd_catalog_name: catalog
    #vcd_api_version: '35.2'

  tasks:
  - name: list catalog items
    vcd_catalog:
      hostname: '{{ vcd_server }}'
      user: '{{ vcd_username }}'
      password: '{{ vcd_password }}'
      org: '{{ vcd_org }}'
      vdc: '{{ vcd_vdc }}'
      verify_ssl_certs: false
      catalog_name: "{{ vcd_catalog_name }}"
      #api_version: "{{ vcd_api_version }}"
      operation: "list_items"
    register: catalog_items

  - debug:
      var: catalog_items
----------------------------------
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1645127368.5775847-945938-1591037645220/AnsiballZ_vcd_catalog.py", line 100, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1645127368.5775847-945938-1591037645220/AnsiballZ_vcd_catalog.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1645127368.5775847-945938-1591037645220/AnsiballZ_vcd_catalog.py", line 41, in invoke_module
    run_name='__main__', alter_sys=True)
  File "/usr/lib64/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_vcd_catalog_payload_jEkhbg/ansible_vcd_catalog_payload.zip/ansible/modules/vcd_catalog.py", line 97, in <module>
ImportError: No module named pyvcloud.vcd.org
---------------------------------------
ansible --version
ansible [core 2.11.8]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible_venv/lib64/python3.6/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/ansible_venv/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 2.11.3
  libyaml = True
---------------------------------------
ansible-config dump |grep DEFAULT_MODULE_PATH
DEFAULT_MODULE_PATH(default) = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
---------------------------------------
python
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyvcloud.vcd.org import Org
>>> from pyvcloud.vcd.client import NSMAP
>>> from ansible.module_utils.vcd import VcdAnsibleModule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ansible.module_utils.vcd'
--------------------------------
pip3 install pyvcloud
Requirement already satisfied: pyvcloud in /root/ansible_venv/lib/python3.6/site-packages (23.0.3)
Requirement already satisfied: python-dateutil>=2.8.1 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (2.8.2)
Requirement already satisfied: vcd-api-schemas-type>=9.1.2.dev10 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (10.3.0.dev72)
Requirement already satisfied: PyYAML>=4.2b1 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (5.4.1)
Requirement already satisfied: packaging>=21.0 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (21.3)
Requirement already satisfied: humanfriendly>=4.8 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (10.0)
Requirement already satisfied: lxml>=4.2.1 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (4.7.1)
Requirement already satisfied: unittest-xml-reporting>=2.2.1 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (3.1.0)
Requirement already satisfied: requests>=2.18.4 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (2.25.1)
Requirement already satisfied: pygments>=2.2.0 in /root/ansible_venv/lib/python3.6/site-packages (from pyvcloud) (2.11.2)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /root/ansible_venv/lib/python3.6/site-packages (from packaging>=21.0->pyvcloud) (2.4.7)
Requirement already satisfied: six>=1.5 in /root/ansible_venv/lib/python3.6/site-packages (from python-dateutil>=2.8.1->pyvcloud) (1.15.0)
Requirement already satisfied: certifi>=2017.4.17 in /root/ansible_venv/lib/python3.6/site-packages (from requests>=2.18.4->pyvcloud) (2020.12.5)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /root/ansible_venv/lib/python3.6/site-packages (from requests>=2.18.4->pyvcloud) (1.26.3)
Requirement already satisfied: chardet<5,>=3.0.2 in /root/ansible_venv/lib/python3.6/site-packages (from requests>=2.18.4->pyvcloud) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /root/ansible_venv/lib/python3.6/site-packages (from requests>=2.18.4->pyvcloud) (2.10)
----------------------------------
/root/.ansible/plugins/modules/vcd_catalog_item.py
/root/.ansible/plugins/modules/vcd_disk.py
/root/.ansible/plugins/modules/vcd_external_network.py
/root/.ansible/plugins/modules/vcd_gateway_services.py
/root/.ansible/plugins/modules/vcd_org.py
/root/.ansible/plugins/modules/vcd_org_vdc.py
/root/.ansible/plugins/modules/vcd_resources.py
/root/.ansible/plugins/modules/vcd_roles.py
/root/.ansible/plugins/modules/vcd_user.py
/root/.ansible/plugins/modules/vcd_vapp_network.py
/root/.ansible/plugins/modules/vcd_vapp.py
/root/.ansible/plugins/modules/vcd_vapp_vm_disk.py
/root/.ansible/plugins/modules/vcd_vapp_vm_nic.py
/root/.ansible/plugins/modules/vcd_vapp_vm.py
/root/.ansible/plugins/modules/vcd_vapp_vm_snapshot.py
/root/.ansible/plugins/modules/vcd_vdc_gateway.py
/root/.ansible/plugins/modules/vcd_vdc_network.py
/root/.ansible/plugins/modules/vcd_catalog.py
/root/.ansible/plugins/module_utils
/root/.ansible/plugins/module_utils/gateway_firewall_service.py
/root/.ansible/plugins/module_utils/gateway_nat_rule_service.py
/root/.ansible/plugins/module_utils/gateway_ssl_certificates.py
/root/.ansible/plugins/module_utils/gateway_static_route.py
/root/.ansible/plugins/module_utils/vcd_errors.py
/root/.ansible/plugins/module_utils/vcd.py
/root/.ansible/plugins/module_utils/vcd_resources_endpoint.py
-----------------------------------------
CentOS Linux release 7.9.2009 (Core)
----------------------------------------

Reproduction steps

...

Expected behavior

List catalog

Additional context

No response

@theovich theovich added the bug Something isn't working label Feb 17, 2022
@mukultaneja
Copy link
Collaborator

@theovich I could see two issues here,

  1. You have installed pyvcloud for python 3.6 but somehow it is looking for python 2.7.
  2. Did you have ansible.cfg in the same folder which is part of this project? This config tells actually where to look for modules and their utilities.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants