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

Problem with samples.vsphere.common.sample_cli #172

Closed yishaihl closed 5 years ago

yishaihl commented 5 years ago

Hey guys, i'm using mac with Pycharm, Python ver. 3.7.3. installed all requirements: Ignoring suds: markers 'python_version < "3"' don't match your environment Requirement already satisfied: lxml>=4.3.0 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (4.3.4) Requirement already satisfied: pyVmomi>=6.7 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (6.7.1.2018.12) Requirement already satisfied: suds-jurko in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (0.6) Requirement already satisfied: vapi-client-bindings==3.0.0 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (3.0.0) Requirement already satisfied: vmc-client-bindings in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (1.9.0) Requirement already satisfied: nsx-python-sdk in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (2.3.0.0.3.13851140) Requirement already satisfied: nsx-policy-python-sdk in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (2.3.0.0.3.13851140) Requirement already satisfied: nsx-vmc-policy-python-sdk in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 9)) (2.3.0.0.3.13851140) Requirement already satisfied: nsx-vmc-aws-integration-python-sdk in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from -r requirements.txt (line 10)) (2.3.0.0.3.13851140) Requirement already satisfied: requests>=2.3.0 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from pyVmomi>=6.7->-r requirements.txt (line 2)) (2.22.0) Requirement already satisfied: six>=1.7.3 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from pyVmomi>=6.7->-r requirements.txt (line 2)) (1.12.0) Requirement already satisfied: vapi-runtime>=2.9.0 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (2.12.0) Requirement already satisfied: setuptools in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (41.0.1) Requirement already satisfied: vapi-common-client in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from vmc-client-bindings->-r requirements.txt (line 6)) (2.12.0) Requirement already satisfied: certifi>=2017.4.17 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from requests>=2.3.0->pyVmomi>=6.7->-r requirements.txt (line 2)) (2019.6.16) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from requests>=2.3.0->pyVmomi>=6.7->-r requirements.txt (line 2)) (3.0.4) Requirement already satisfied: idna<2.9,>=2.5 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from requests>=2.3.0->pyVmomi>=6.7->-r requirements.txt (line 2)) (2.8) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from requests>=2.3.0->pyVmomi>=6.7->-r requirements.txt (line 2)) (1.25.3) Requirement already satisfied: pyOpenSSL>=18.0.0 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from vapi-runtime>=2.9.0->vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (19.0.0) Requirement already satisfied: cryptography>=2.3 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from pyOpenSSL>=18.0.0->vapi-runtime>=2.9.0->vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (2.7) Requirement already satisfied: asn1crypto>=0.21.0 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from cryptography>=2.3->pyOpenSSL>=18.0.0->vapi-runtime>=2.9.0->vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (0.24.0) Requirement already satisfied: cffi!=1.11.3,>=1.8 in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from cryptography>=2.3->pyOpenSSL>=18.0.0->vapi-runtime>=2.9.0->vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (1.12.3) Requirement already satisfied: pycparser in /Users/yishaihl/PycharmProjects/vSphere_Automation/venv/lib/python3.7/site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.3->pyOpenSSL>=18.0.0->vapi-runtime>=2.9.0->vapi-client-bindings==3.0.0->-r requirements.txt (line 5)) (2.19)

But i can't import sample_cli & sample_util & practically anything imported from vsphere.common.

Any idea why?..

Thanks a lot!

Screen Shot 2019-07-23 at 11 05 28

Screen Shot 2019-07-23 at 11 08 03

yishaihl commented 5 years ago

?

xeacott commented 5 years ago

I also noticed this between version 1.0.0 and 1.3.0. Try installing 1.0.0 and see if the issue still persists, and then maybe check what changed between versions

yishaihl commented 5 years ago

1.0.0 version for?

xeacott commented 5 years ago

For the vSphere Automation SDK. Version 1.0.0 had no import issues when importing from the package itself, however in 1.3.0 I noticed importing from samples was problematic.

tianhao64 commented 5 years ago

@yishaihl @xeacott Have you added the folder contains these util methods to python path? https://github.com/vmware/vsphere-automation-sdk-python#first-set-pythonpath-to-use-sdk-helper-methods

yishaihl commented 5 years ago

@tianhao64 you mean the export PYTHONPATH=${PWD}:$PYTHONPATH ?..

yishaihl commented 5 years ago

just to clarify, im using the latest vSphere-Automation-SDK-1.3.0 and Python 3.7 interperter.

xeacott commented 5 years ago

No, but I can do that and report back...

yishaihl commented 5 years ago

@xeacott hey, you understood what it means to add the util methods to the Python path?

tianhao64 commented 5 years ago

@xeacott @yishaihl Is it working after adding the sdk root folder to PYTHONPATH? There are some helper methods in samples folder which are not installed in the python's site-package folder. So to use them you have to add the sdk root folder to PYTHONPATH. Closing this for now. Please let me know if you still have issue with these imports

varun030190 commented 4 years ago

Which path we need to add in environment variable?