Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use the python3 bindings for VirtualBox?

I am trying to use the python 3 bindings to VirtualBox but there appears to be broken dependencies. It seems odd to me that this hasn't been fixed over the ~4 years that people have been having this issue. Perhaps I'm missing something obvious. It's been known to happen.

I have installed the virtualbox host modules, sdk, and extensions through my OS's pacakage manager. Then, through pip:

pip install pyvbox

The imports work:

from virtualbox import VirtualBox, Session, Manager, WebServiceManager

But then any attempt to instantiate anything results in an exception complaining about a missing vboxapi.

box = VirtualBox()

Traceback:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/virtualbox/library_ext/vbox.py", line 22, in __init__
    manager = virtualbox.Manager()
  File "/usr/lib/python3.6/site-packages/virtualbox/__init__.py", line 130, in __init__
    with import_vboxapi() as vboxapi:
  File "/usr/lib/python3.6/contextlib.py", line 82, in __enter__
    return next(self.gen)
  File "/usr/lib/python3.6/site-packages/virtualbox/__init__.py", line 45, in import_vboxapi
    import vboxapi
  File "/home/$USER/.eclipse/org.eclipse.platform_4.6.3_155965261_linux_gtk_x86_64/plugins/org.python.pydev_5.7.0.201704111357/pysrc/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'vboxapi'

There is a vboxapi on PyPi, but it won't install as there is no code associated with it, nor any useful information on the PyPi page: https://pypi.python.org/pypi/vboxapi

Here are a couple links to the valiant efforts of braver souls than I. It is not immediately clear to me which is the correct solution or if either are still relevant, given that they are from 3 and 4 years ago, respectively.

https://github.com/GreatFruitOmsk/vboxapi-py3

https://github.com/jbuergel/vboxapi-py3

Also from 3 years ago, word of a vboxapi.diff and intergration into vboxapi:

https://www.virtualbox.org/pipermail/vbox-dev/2014-April/012231.html

like image 966
Inversus Avatar asked Jun 10 '17 19:06

Inversus


People also ask

Does VirtualBox need Python?

Python is one of the supported languages. The manual, https://www.virtualbox.org/manual/ch02. ... performing, says: Python version at least 2.6 is required.

How do I install Python on VirtualBox?

Installation. Go to VirtualBox's downloads page (https://www.virtualbox.org/wiki/Downloads) and download the VirtualBox SDK. Within the extracted ZIP file there is a directory called “installer”. Open a console within the installer directory and run python vboxapisetup.py install using your system Python.


1 Answers

I'm the current maintainer of the pyvbox package. The VirtualBox SDK already supports Python 3, I use Python 3.5 to develop the library. I recommend uninstalling and reinstalling the latest version of the SDK (which at the time of writing this is 5.1.22).

You can find the SDK on the VirtualBox downloads page. Unzip the archive and run the vboxapisetup.py file using your system Python with the following command:

python vboxapisetup.py install

You don't need to install this in any virtualenv, as pyvbox will search your system libraries in addition to virtualenv installations for better ease of use.

If you have problems using the pyvbox package after running these steps, please open an issue and include as much information as possible including the steps you took, OS, where your system Python is located, which version of VirtualBox & SDK you're using, and I'll help you as best I can.

like image 70
sethmlarson Avatar answered Oct 20 '22 11:10

sethmlarson