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
748 stars 311 forks source link

ModuleNotFoundError: No module named 'samples' #219

Closed synergiator closed 4 years ago

synergiator commented 4 years ago

To better isolate the problem, I've created the Dockerfile below which installs all dependencies in a Python3 environment and runs a sample file.

For some reason, the module "samples" is not recognized. Why?

FROM python:3
COPY . /app/
WORKDIR /app/
RUN python3 --version &&\ 
    pip3 install lib/vapi-runtime/vapi_runtime-2.15.0-py2.py3-none-any.whl &&\
    pip3 install lib/vapi-common-client/vapi_common_client-2.15.0-py2.py3-none-any.whl &&\
    pip3 install lib/nsx-vmc-policy-python-sdk/nsx_vmc_policy_python_sdk-2.5.1.0.1.15419398-py2.py3-none-any.whl &&\
    pip3 install lib/vmc-draas-client-bindings/vmc_draas_client_bindings-1.5.0-py2.py3-none-any.whl &&\
    pip3 install lib/vapi-client-bindings/vapi_client_bindings-3.3.0-py2.py3-none-any.whl &&\
    pip3 install lib/nsx-vmc-aws-integration-python-sdk/nsx_vmc_aws_integration_python_sdk-2.5.1.0.1.15419398-py2.py3-none-any.whl &&\
    pip3 install lib/nsx-python-sdk/nsx_python_sdk-2.5.1.0.1.15419398-py2.py3-none-any.whl &&\
    pip3 install lib/nsx-policy-python-sdk/nsx_policy_python_sdk-2.5.1.0.1.15419398-py2.py3-none-any.whl &&\
    pip3 install lib/vmc-client-bindings/vmc_client_bindings-1.24.0-py2.py3-none-any.whl &&\
    pip3 install -r requirements.txt

RUN python3 samples/vsphere/vcenter/vm/create/create_basic_vm.py

Error:

Traceback (most recent call last):
  File "samples/vsphere/vcenter/vm/create/create_basic_vm.py", line 27, in <module>
    from samples.vsphere.common.ssl_helper import get_unverified_session
ModuleNotFoundError: No module named 'samples'
anusha94 commented 4 years ago

@synergiator Please set the PYTHONPATH to your app/ directory Refer to this installation step

Thanks!

synergiator commented 4 years ago

works, thank you!