vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
745 stars 313 forks source link

No Module Named 'vmware' #418

Closed dlayne1 closed 6 months ago

dlayne1 commented 6 months ago

Describe the bug

I tried installing the SDK using pip as instructed in the readme but I am still being prompted with an error when I try to run my code with the SDK to create a session. The error is ModuleNotFoundError: No module named 'vmware'. The line of code that is prompting the error is from vmware.vapi.vsphere.client import create_vsphere_client. I am running Windows with Python at version 3.9.9 and PIP at version 24.0.

Reproduction steps

  1. pip install --upgrade pip
  2. pip install --upgrade setuptools
  3. pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
  4. run python code using sdk ...

Expected behavior

The expected behavior is to be able to import the SDK Packages into my code.

Additional context

No response

kunalpmj commented 6 months ago

Can you share the complete error from console, the Traceback? To verify all packages were installed, do a pip list and share the result.

Libraries relevant to automation SDK are

lxml 5.1.0 nsx-policy-python-sdk 4.1.2.0.0 nsx-python-sdk 4.1.2.0.0 nsx-vmc-aws-integration-python-sdk 4.1.2.0.0 nsx-vmc-policy-python-sdk 4.1.2.0.0 pyvmomi 8.0.2.0.1 requests 2.31.0 six 1.16.0 urllib3 2.2.1 vapi-common-client 2.44.0 vapi-runtime 2.44.0 vcenter-bindings 4.2.0 vmwarecloud-aws 1.64.0 vmwarecloud-draas 1.23.0 vsphere-automation-sdk 1.86.0

dlayne1 commented 6 months ago

Pip List: image Complete Error: image

kunalpmj commented 6 months ago

create_vsphere_client is proided by vcenter-bindings which is present in the list of installed packages. Btw, if you have installed the SDK on a virtual environment then you need to activate that environment in the terminal before executing CreateVSphereLibraryItem.py

dlayne1 commented 6 months ago

I was able to get it to work after setting up a virtual environment then installing the SDK. Thank you!