sethmlarson / virtualbox-python

Complete implementation of VirtualBox's COM API with a Pythonic interface.
https://pypi.org/project/virtualbox
Apache License 2.0
354 stars 75 forks source link

Exception: Cannot find VBoxPython module (tried: VBoxPython2_7, VBoxPython2, VBoxPython) #136

Closed lzwgiter closed 4 years ago

lzwgiter commented 4 years ago

ENVIRONMENT

SUMMARY

I installed pyvbox and virtualbox using pip install, also I install the SDK 6.0.16 using command python vboxapisetup.py install. when I am trying to use it with python2.7, I got these errors:

>>> import virtualbox
>>> vbox = virtualbox.VirtualBox()
m=VBoxPython2_7 x=No module named VBoxPython2_7
m=VBoxPython2 x=No module named VBoxPython2
m=VBoxPython x=/usr/lib/virtualbox/VBoxPython.so: undefined symbol: _Py_FalseStruct
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/float/.local/lib/python2.7/site-packages/virtualbox/library_ext/vbox.py", line 22, in __init__
    manager = virtualbox.Manager()
  File "/home/float/.local/lib/python2.7/site-packages/virtualbox/__init__.py", line 145, in __init__
    self.manager = vboxapi.VirtualBoxManager(mtype, mparams)
  File "vboxapi/__init__.py", line 989, in __init__
    self.platform = PlatformXPCOM(dPlatformParams)
  File "vboxapi/__init__.py", line 750, in __init__
    import xpcom.vboxxpcom
  File "/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/vboxxpcom.py", line 78, in <module>
    raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),))
Exception: Cannot find VBoxPython module (tried: VBoxPython2_7, VBoxPython2, VBoxPython)

It seems some thing wrong with the file /usr/lib/virtualbox/VBoxPython.so, and I try to renamed it as VBoxPython2_7.so but it doesn't work.

plus, when I do the same thing above with python 3.8, it comes with no problem.

sethmlarson commented 4 years ago

It sounds like your VBoxPython isn't built for Python 2.7, you probably installed it with Python 3.8? You can only use the VBoxPython.so with the Python version which it was built for.