如何在 Mac 上安装 VirtualBox SDK
似乎没有任何关于如何执行此操作的文档。我进入 /sdk/installer
并运行 vboxsetup.py
脚本,但它引发了以下异常:
Exception: No VBOX_INSTALL_PATH defined, exiting
There does not seem to be any documentation on how to do it. I went into /sdk/installer
and ran the vboxsetup.py
script but it raised the following exception:
Exception: No VBOX_INSTALL_PATH defined, exiting
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
他们没有充分解释如何安装它,这真的很烦人,而且很奇怪的是,virtualbox 安装本身没有创建 VBOX_INSTALL_PATH 变量。
无论如何,这对我有用:
It is really annoying that they don't adequately explain how to install it and it's weird that the virtualbox installation does not create the VBOX_INSTALL_PATH variable by itself.
Anyways, This is what worked for me:
这是一个通过 Python 面向对象 Web 服务从 VirtualBox SDK 运行 Python 演示脚本
vboxshell.py
的最小示例。测试环境:
系统:macOS 10.15.2
VirtualBox 版本:6.0.14
说明:
为 macOS 安装 VirtualBox
从 VirtualBox 网站下载 SDK(即 https://download.virtualbox.org/virtualbox/6.1。 0/VirtualBoxSDK-6.1.0-135406.zip)并解压到
$HOME/vboxtest/sdk
mkdir $HOME/vboxtest
创建一个 python2 venv:
禁用身份验证(用于测试):
VBoxManage setproperty websrvauthlibrary null
安装 SDK python 模块:
启动 API Webserver:
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv -t 0
启动实际的演示脚本:
您应该获得一个 virtualbox shell,您可以在其中列出所有虚拟机:
有关更多信息,请检查 SDK文档: https://download.virtualbox.org/virtualbox/SDKRef.pdf
(恕我直言,应谨慎使用,因为 Python2 和 ZSI 均已停产)。
this is a minimal example for running the Python demo script
vboxshell.py
from the VirtualBox SDK via the Object Oriented Web Service for Python.Tested with:
System: macOS 10.15.2
VirtualBox version: 6.0.14
Instructions:
install VirtualBox for macOS
download SDK from the VirtualBox website (i.e. https://download.virtualbox.org/virtualbox/6.1.0/VirtualBoxSDK-6.1.0-135406.zip) and extract to
$HOME/vboxtest/sdk
mkdir $HOME/vboxtest
create a python2 venv:
disable auth (for testing):
VBoxManage setproperty websrvauthlibrary null
install SDK python module:
start API webserver:
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv -t 0
start the actual demo script:
You should be getting a virtualbox shell, in which you can i.e. list all vms:
For more infos check the SDK docs: https://download.virtualbox.org/virtualbox/SDKRef.pdf
(IMHO should be used with caution as both Python2 and ZSI are EOL).
五年过去了,事情似乎并没有太大进展。
在 Mojave 下,我已经安装了 python2 (2.7.15) 和 python3 (3.7.0),并且我必须执行以下操作:
内置 Mojave 版本的 Python (
/usr/bin/python
版本 2.7.10) 是唯一可以在 VirtualBox 安装后导入 vboxapi
的版本。我必须手动添加其他 Python 版本。我能找到的关于此的唯一说明位于 SDK 参考的第 40 页,其中建议:
但是,当然没有提及环境变量。正如 Tal 在已接受的答案中指出的那样,有趣的是,他们可能会费心编写 440 页的 SDK 手册,但却没有提及这一点。
Five years later, things haven't progressed much it seems.
Under Mojave, I had brew installed python2 (2.7.15) and python3 (3.7.0), and I had to do the following:
The built-in Mojave version of Python (
/usr/bin/python
version 2.7.10) was the only one that couldimport vboxapi
after the VirtualBox install. I had to add the other Python versions manually.The only instruction regarding this that I could find comes on page 40 of the SDK ref, where it suggests:
But, of course no mention of an environment variable. As Tal points out in the accepted answer, interesting that they can be bothered to write a 440 page SDK manual, and yet fail to mention this.
使用虚拟环境的简单方法
我尝试仅使用python 3。对于Mac OS上的pyvbox API,我使用第二个virtualenv,即python 2 Python2 venv
基础设置:
我仍然几乎只使用 python3,然后使用 subprocess.Popen 初始化 venvpy2 并运行 python2 模块。将
stdout
和stderr
返回到主控制python3
代码中。完成此操作后,我得出的结论是,适合我的用例的更好方法是使用命令行vboxmanage
自动化 Box 服务器设置Simple approach using virtual environs
I try to only use python 3. For pyvbox API on Mac OS I'm using a second virtualenv which is python 2 Python2 venv
Base set up:
I still pretty much only use python3, then use
subprocess.Popen
initialisevenvpy2
and runpython2
module. Takestdout
andstderr
back into main controllingpython3
code. Having got this to work, I've concluded better approach for my use case is use command linevboxmanage
Automate box server setup