I have ubuntu18.04 with default VirtualBox installed, guest is xubuntu 18.04, with following code takepic.py:
import pyscreenshot as ImageGrab
import virtualbox
def getpic():
vbox = virtualbox.VirtualBox()
vm_list = [vm.name for vm in vbox.machines]
print(vm_list[0])
vm = vbox.find_machine(vm_list[0])
session = vm.create_session()
h, w, _, _, _, _ = session.console.display.get_screen_resolution(0)
png = session.console.display.take_screen_shot_to_array(0, h, w, virtualbox.library.BitmapFormat.png)
if __name__ == '__main__':
getpic()
got error:
xubuntu11
Traceback (most recent call last):
File "/home/weilo/.local/lib/python3.6/site-packages/virtualbox/library_base.py", line 201, in _call_method
ret = method(*in_params)
File "<XPCOMObject method 'takeScreenShotToArray'>", line 3, in takeScreenShotToArray
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "jjj.py", line 15, in <module>
getpic()
......
this is picture, utf should not get into it, not sure where the problem?