You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to import using PyCharm, using for example VirtualMachine, it imports pyVmomi.vim.VirtualMachine, but the correct import is vim.VirtualMachine. This causes errors during runtime.
Reproduction steps
Try to import some type automatically
Run the code and get error: ImportError: cannot import name 'VirtualMachine' from 'pyVmomi.vim' (unknown location)
Expected behavior
Import would be correct: from vim import VirtualMachine
Additional context
No response
The text was updated successfully, but these errors were encountered:
importpyVmomi.vimasvimprint(vim.Task)
# Result (unexpected): AttributeError: module 'pyVmomi.vim' has no attribute 'Task'
While this equivalent-at-a-glance code works:
frompyVmomiimportvimprint(vim.Task)
# Result (expected): <class 'pyVmomi.VmomiSupport.vim.Task'>
Furthermore, if e.g. import pyVmomi.vim is called first, it breaks the module within that python runtime, for example:
importpyVmomi.vimfrompyVmomiimportvimprint(vim.Task)
# Result (unexpected): AttributeError: module 'pyVmomi.vim' has no attribute 'Task'
If this is not easy to fix, I'd recommend adding something like raise ImportError('Use "from pyVmomi import vim" ...') when module is imported via import X, which should be detectable via same missing class-attribute lookups.
This way, at least it'd be clear what the issue is, as otherwise it looks like module and all example code for it is outdated or broken in current pip releases, as it tries to use no-longer-existant module attributes.
Describe the bug
When trying to import using PyCharm, using for example
VirtualMachine
, it importspyVmomi.vim.VirtualMachine
, but the correct import isvim.VirtualMachine
. This causes errors during runtime.Reproduction steps
Try to import some type automatically
![image](https://private-user-images.githubusercontent.com/38400710/244367164-3d9432cd-6d31-41d4-9f52-bc2ced937fa4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTQ0MjUsIm5iZiI6MTczOTU5NDEyNSwicGF0aCI6Ii8zODQwMDcxMC8yNDQzNjcxNjQtM2Q5NDMyY2QtNmQzMS00MWQ0LTlmNTItYmMyY2VkOTM3ZmE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDA0MzUyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzY2YzZGMwMzVhMjg3MjQyNmViZWM2ZjY2NzI0MmEzYTBlMDkwMzUwMzdhMDg0NDcyYTBhMmY0OWJkMTk2NTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.150dGvjdBIOOVkCViR9r5ZSMdZEBaDkAA8pi-i_Q_Js)
Run the code and get error:
ImportError: cannot import name 'VirtualMachine' from 'pyVmomi.vim' (unknown location)
Expected behavior
Import would be correct:
from vim import VirtualMachine
Additional context
No response
The text was updated successfully, but these errors were encountered: