I have a local installation of VirtualBox running on my host machine, which is running Windows 10. I am able to start and run a virtual machine of Ubuntu via the VirtualBox GUI application.
I need to be able to manage the state of that virtual machine using python. As far as I know, the only routes for me to pursue this are:
virtualbox-python
library on Github (last active 2020, build failing)vboxapi
library on PyPi (last active 2012, build failing)virtual-machines-python-manage
, which I have not attempted to use since it requires Azure services (which eventually require a paid subscription)Using this very similar post from June 2017, which was answered by the vboxapi
maintainer/virtualbox-python
repo hoster at that time, I've surmised that the process should be to easily import the virtualbox
or vboxapi
libraries.
However, when I run a function of either library, I receive the error No module named 'vboxapi
'.
To fix this, I should be able to:
python vboxapisetup.py install
.This should install vboxapi
, but instead I receive the following error:
C:\Users\PATH_HERE\VirtualBoxSDK-6.1.30-148432\sdk\installer>python vboxapisetup.py install
Cleaning COM cache at C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Lib\site-packages\win32com\gen_py and C:\Users\USER_HERE\AppData\Local\Temp\gen_py
running install
running build
running build_py
copying vboxapi\__init__.py -> build\lib\vboxapi
running install_lib
creating C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Lib\site-packages\vboxapi
error: could not create 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Lib\site-packages\vboxapi': Access is denied
Is this a Path error? Am I overlooking something simple in environmental variables?
This post for the same problem on a ubuntu host machine suggests running the following commands:
export VBOX_INSTALL_PATH=$(which VirtualBox)
sudo -E python vboxapisetup.py install
Is there a windows equivalent method I can try here?
So I was never able to directly run any sort of VirtualBox management software from within python: none of the libraries listed worked for me.
Instead, what I ended up doing was execute bash shell scripts that called VBoxManage and each subsequent command needed. I then had to pipe the results (text output to the terminal from VBoxManage) back into Python and parse the text.