Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 2.1.1 instead.
Reason given by maintainers: Release is broken, use 2.0.0 for now

https://img.shields.io/travis/sethmlarson/virtualbox-python/master.svg

Complete implementation of VirtualBox’s COM API with a Pythonic interface.

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. This installs vboxapi which is the interface that talks to VirtualBox via COM.

Next is to install this library:

To get the latest released version of virtualbox from PyPI run the following:

$ python -m pip install virtualbox

or to install the latest development version from GitHub:

$ git clone https://github.com/sethmlarson/virtualbox-python
$ cd virtualbox-python
$ python setup.py install

Getting Started

Listing Available Machines

>>> import virtualbox
>>> vbox = virtualbox.VirtualBox()
>>> [m.name for m in vbox.machines]
["windows"]

Launching a Machine

>>> session = virtualbox.Session()
>>> machine = vbox.find_machine("windows")
>>> # progress = machine.launch_vm_process(session, "gui", "")
>>> # For virtualbox API 6_1 and above (VirtualBox 6.1.2+), use the following:
>>> progress = machine.launch_vm_process(session, "gui", [])
>>> progress.wait_for_completion()

Querying the Machine

>>> session.state
SessionState(2)  # locked
>>> machine.state
MachineState(5)  # running
>>> height, width, _, _, _, _ = session.console.display.get_screen_resolution()

Interacting with the Machine

>>> session.console.keyboard.put_keys("Hello, world!")
>>> guest_session = session.console.guest.create_session("Seth Larson", "password")
>>> guest_session.directory_exists("C:\\Windows")
True
>>> proc, stdout, stderr = guest_session.execute("C:\\\\Windows\\System32\\cmd.exe", ["/C", "tasklist"])
>>> print(stdout)
Image Name                   PID Session Name     Session#    Mem Usage
========================= ====== ================ ======== ============
System Idle Process            0 Console                 0         28 K
System                         4 Console                 0        236 K
smss.exe                     532 Console                 0        432 K
csrss.exe                    596 Console                 0      3,440 K
winlogon.exe                 620 Console                 0      2,380 K
services.exe                 664 Console                 0      3,780 K
lsass.exe                    676 Console                 0      6,276 K
VBoxService.exe              856 Console                 0      3,972 K
svchost.exe                  900 Console                 0      4,908 K
svchost.exe                 1016 Console                 0      4,264 K
svchost.exe                 1144 Console                 0     18,344 K
svchost.exe                 1268 Console                 0      2,992 K
svchost.exe                 1372 Console                 0      3,948 K
spoolsv.exe                 1468 Console                 0      4,712 K
svchost.exe                 2000 Console                 0      3,856 K
wuauclt.exe                  400 Console                 0      7,176 K
alg.exe                     1092 Console                 0      3,656 K
wscntfy.exe                 1532 Console                 0      2,396 K
explorer.exe                1728 Console                 0     14,796 K
wmiprvse.exe                1832 Console                 0      7,096 K
VBoxTray.exe                1940 Console                 0      3,196 K
ctfmon.exe                  1948 Console                 0      3,292 K
cmd.exe                     1284 Console                 0      2,576 K
tasklist.exe                 124 Console                 0      4,584 K

Registering Event Handlers

>>> def test(event):
>>>    print("scancode received: %r" % event.scancodes)
>>>
>>> session.console.keyboard.set_on_guest_keyboard(test)
140448201250560
scancode received: [35]
scancode received: [23]
scancode received: [163]
scancode received: [151]
scancode received: [57]

Powering-Down a Machine

>>> session.console.power_down()

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvbox-2.1.0.tar.gz (283.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvbox-2.1.0-py2.py3-none-any.whl (275.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyvbox-2.1.0.tar.gz.

File metadata

  • Download URL: pyvbox-2.1.0.tar.gz
  • Upload date:
  • Size: 283.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pyvbox-2.1.0.tar.gz
Algorithm Hash digest
SHA256 4abe0f1d9641f7476ca88826a3d792e37b0078dc172df919fc59b5f79e149c74
MD5 918a82f70e0c4a1b042e24b5d9b891e6
BLAKE2b-256 5351a1f8576dcd82bf86d6c960e7670faeecdad458d10db247bd38a5ab0709d0

See more details on using hashes here.

File details

Details for the file pyvbox-2.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyvbox-2.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 275.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pyvbox-2.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c5a14d075c62455807916e415c9571471c9fe54d7b3812d2ce319986c26efdb6
MD5 358a5f96ab736ca7d90263033431f83c
BLAKE2b-256 66733540e633d1b8698ff70febb8b2aa89e4e386141abb6975d23f703eb5d8d2

See more details on using hashes here.

Release history Release notifications | RSS feed

2.1.1

2 files

This release

2.1.0 This release

2 files

1.3.2

1 file

1.3.1

1 file

1.2.0

1 file

1.1.0

1 file

1.0.0

1 file

0.2.2

1 file

0.2.1

0.2.0

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

0.0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page