virtualbox-python: Exception: Cannot find VBoxPython module (tried: VBoxPython3_6, VBoxPython3, VBoxPython)

ENVIRONMENT
  • Operating System: macOS High Sierra 10.13.6
  • Python version: Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin- VirtualBox version:
  • VirtualBox SDK version: /Applications/VirtualBox.app/Contents/MacOS/sdk/- Location where VirtualBox SDK is installed:/Applications/VirtualBox.app/Contents/MacOS/sdk/installer
  • pyvbox version:1.3.2
  • [Not Sure] Happens in latest master branch?
SUMMARY

It doesn’t work even after setting up paths.

STEPS TO REPRODUCE
import virtualbox
vbox = virtualbox.VirtualBox()
EXPECTED RESULTS
ACTUAL RESULTS
m=VBoxPython3_6 x=No module named 'VBoxPython3_6'
m=VBoxPython3 x=No module named 'VBoxPython3'
m=VBoxPython x=No module named 'VBoxPython'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.6/site-packages/virtualbox/library_ext/vbox.py", line 22, in __init__
    manager = virtualbox.Manager()
  File "/anaconda3/lib/python3.6/site-packages/virtualbox/__init__.py", line 143, in __init__
    self.manager = vboxapi.VirtualBoxManager(mtype, mparams)
  File "/anaconda3/lib/python3.6/site-packages/vboxapi/__init__.py", line 989, in __init__
    self.platform = PlatformXPCOM(dPlatformParams)
  File "/anaconda3/lib/python3.6/site-packages/vboxapi/__init__.py", line 750, in __init__
    import xpcom.vboxxpcom
  File "/Applications/VirtualBox.app/Contents/MacOS/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: VBoxPython3_6, VBoxPython3, VBoxPython)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 32 (8 by maintainers)

Most upvoted comments

@SethMichaelLarson I think it’s not loading because VirtualBox.app on macOS is shipped only with VBoxPython2_6.so and VBoxPython2_7.so. That’s likely because macOS does not ship Python 3 at all. You need to somehow compile VBoxPython for your Python first before you can use the bindings.

For those who still have the problem., I manage to solve it by scavenging the VBoxPython3_8.so from the Ubuntu 6.26 package. It is not in the Oracle PPA package, but somehow, you can find it in the slower ubuntu package.

Then:

sudo cp VBoxPython3_8.so /usr/lib/virtualbox/

Which link are you talking about? Is it this one?

FYI As a workaround I created a Dockerfile to build a minimal VirtualBox from source on bionic, then you can copy the two required files to your local install.

sudo docker cp vbox-build:/VirtualBox/out/linux.amd64/release/obj/VBoxPython/VBoxPython.so /usr/lib/virtualbox/
sudo docker cp vbox-build:/VirtualBox/out/linux.amd64/release/obj/VBoxPython3_6m/VBoxPython3_6m.so /usr/lib/virtualbox/