首页 > 解决方案 > 无法在 python 可执行文件中执行 VBoxManage 命令(使用 pyinstaller 创建)

问题描述

操作系统:Ubuntu 16.04 LTS

使 install.py 文件可执行:

pyinstaller -w install.py --onefile

install.py 脚本:

import os
VM = os.system('VBoxManage startvm win10 --type headless')
if VM == 0:
   print("win10 started...")
else:
   print("win10 not started....")

问题:当我python3 install.py在 ubuntu 终端上运行时,它工作正常。之后,我使用上面提到的命令创建了一个可执行文件,当我通过给出命令在终端上执行可执行文件时chmod 777 install & ./install。它在下面给出一个错误:

错误:

VBoxManage: error: Failed to create the VirtualBox object!
VBoxManage: error: Code NS_ERROR_FACTORY_NOT_REGISTERED (0x80040154) - Class not registered (extended info not available)
VBoxManage: error: Most likely, the VirtualBox COM server is not running or failed to start.

我不知道出了什么问题 python 脚本可以正常工作,但是当我创建它的可执行文件时,它每次都会给出相同的错误。

提前致谢。

标签: python-3.xlinuxvirtualboxubuntu-16.04pyinstaller

解决方案


推荐阅读