This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

ModuleNotFoundError: No module named 'pyVmomi'

Hi,

I started to use SS in docker (st2 3.4.1, on Python 3.6.9) trying to use the vSphere pack (GitHub - StackStorm-Exchange/stackstorm-vsphere).

Anybody know if this stackstorm-vsphere is compatible with the docker version I have? For instance, trying to run this one gives:

root@4c6f59446f79:/opt/stackstorm/st2/lib/python3.6/site-packages# st2 run vsphere.hello_vsphere
.
id: 609aa2612947a0547d7341e5
action.ref: vsphere.hello_vsphere
context.user: st2admin
parameters: None
status: failed
start_timestamp: Tue, 11 May 2021 15:27:29 UTC
end_timestamp: Tue, 11 May 2021 15:27:31 UTC
result:
exit_code: 1
result: None
stderr: "Traceback (most recent call last):
File “/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py”, line 238, in _get_action_instance
actions_cls = action_loader.register_plugin(Action, self._file_path)
File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/loader.py”, line 166, in register_plugin
module = imp.load_source(module_name, plugin_abs_file_path)
File “/opt/stackstorm/virtualenvs/vsphere/lib/python3.6/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 684, in _load
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/opt/stackstorm/packs/vsphere/actions/hello_vsphere.py”, line 16, in
from vmwarelib.actions import BaseAction
File “/opt/stackstorm/packs/vsphere/actions/vmwarelib/actions.py”, line 21, in
from pyVim import connect
File “/opt/stackstorm/virtualenvs/vsphere/lib/python3.6/site-packages/pyVim/connect.py”, line 230
except ValueError, ve:
^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py”, line 334, in
obj.run()
File “/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py”, line 192, in run
action = self._get_action_instance()
File “/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py”, line 245, in _get_action_instance
raise exc_cls(msg)
SyntaxError: Failed to load action class from file “/opt/stackstorm/packs/vsphere/actions/hello_vsphere.py” (action file most likely doesn’t exist or contains invalid syntax): invalid syntax (connect.py, line 230)

Traceback (most recent call last):
File “/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py”, line 238, in _get_action_instance
actions_cls = action_loader.register_plugin(Action, self._file_path)
File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/loader.py”, line 166, in register_plugin
module = imp.load_source(module_name, plugin_abs_file_path)
File “/opt/stackstorm/virtualenvs/vsphere/lib/python3.6/imp.py”, line 172, in load_source
module = _load(spec)
File “”, line 684, in _load
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/opt/stackstorm/packs/vsphere/actions/hello_vsphere.py”, line 16, in
from vmwarelib.actions import BaseAction
File “/opt/stackstorm/packs/vsphere/actions/vmwarelib/actions.py”, line 21, in
from pyVim import connect
File “/opt/stackstorm/virtualenvs/vsphere/lib/python3.6/site-packages/pyVim/connect.py”, line 230
except ValueError, ve:
^
SyntaxError: invalid syntax

"
stdout: ‘’

This pyVim/connect.py is not found in the virtualenvs directory. I assume this is referring to /opt/stackstorm/st2/lib/python3.6/site-packages/pyVim/connect.py??

root@4c6f59446f79:/opt/stackstorm/st2/lib/python3.6/site-packages# ls -l /opt/stackstorm/virtualenvs/vsphere/lib/python3.6/site-packages/pyVim/connect.py
ls: cannot access ‘/opt/stackstorm/virtualenvs/vsphere/lib/python3.6/site-packages/pyVim/connect.py’: No such file or directory
root@4c6f59446f79:/opt/stackstorm/st2/lib/python3.6/site-packages# find / -name connect.py
/opt/stackstorm/st2/lib/python3.6/site-packages/pyVim/connect.py
/usr/local/lib/python3.6/dist-packages/pyVim/connect.py

In the source file, connect.py, I see:

except ValueError as ve:

This seems like a correct syntax for Python3, but the error above shows:

except ValueError, ve:

So I am pretty confused about where the error is actually coming from.

Furthermore, In the latest VMware vSphere Python SDK, while running sample scripts converted as SS actions, I get ModuleNotFoundError: No module named ‘pyVmomi’ even after installing pyvmoni locally (I have pyvmomi (7.0.2)). These samples files with main in them run ok if I directly run it as python3 file_name.

This is because the code has the top import as:

from pyVmomi import vmodl
from tools import cli, service_instance

Do I need to modify PYTHONPATH or what am I missing to get vSphere actions running? Is this a docker specific issue possibly??

I must be missing something simple… Any info is appreciated. Thanks!

Does /opt/stackstorm/virtualenvs/vsphere exist within the Docker container?

No, it does not. Should I create one with “st2 run packs.setup_virtualenv packs=vsphere”, activate the vsphere’s virtualenv and pip3 install pyvmomi and retry?

Does this virtualenv have to be manually created for any docker pack?

Thank you for your response.

I ran:
st2 run packs.setup_virtualenv packs=vsphere, activated the vsphere’s virtualenv and pip3 install --upgrade pyvmomi.
Though the virtualenv is not accessible under /opt/stackstorm/virtualenvs (vsphere doesn’t exist), st2 vsphere actions appear to run ok now.

Thank you for your input.