{"id":2736,"library":"python-vagrant","title":"Python Vagrant","description":"python-vagrant provides Python bindings for interacting with Vagrant virtual machines, allowing programmatic control over Vagrant environments. The current stable version is 1.0.0. Releases are somewhat irregular but active, with bug fixes and minor features released as needed, typically every few months.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/pycontribs/python-vagrant","tags":["vagrant","virtualization","devops","cli-wrapper"],"install":[{"cmd":"pip install python-vagrant","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Vagrant","correct":"from vagrant import Vagrant"}],"quickstart":{"code":"import vagrant\nimport os\n\n# Ensure you have a Vagrantfile in this directory or provide its root path\n# Example: Create a dummy Vagrantfile for testing if not present\nvagrantfile_path = './test_vagrant_project'\nif not os.path.exists(vagrantfile_path):\n    os.makedirs(vagrantfile_path)\nif not os.path.exists(os.path.join(vagrantfile_path, 'Vagrantfile')):\n    with open(os.path.join(vagrantfile_path, 'Vagrantfile'), 'w') as f:\n        f.write(\"Vagrant.configure(\\\"2\\\") do |config|\\n  config.vm.box = \\\"hashicorp/bionic64\\\"\\nend\")\n\n# Initialize Vagrant object with the root path of the Vagrant project\nv = vagrant.Vagrant(root=vagrantfile_path)\n\ntry:\n    # Bring up the VM\n    print(f\"Bringing up Vagrant VM in {vagrantfile_path}...\")\n    v.up()\n    print(\"VM is up.\")\n\n    # Get VM status\n    status = v.status()\n    for vm_status in status:\n        print(f\"VM Name: {vm_status.name}, Provider: {vm_status.provider}, State: {vm_status.state}\")\n\nfinally:\n    # Destroy the VM\n    print(\"Destroying Vagrant VM...\")\n    v.destroy()\n    print(\"VM destroyed.\")\n    # Clean up dummy Vagrantfile and directory\n    if os.path.exists(os.path.join(vagrantfile_path, 'Vagrantfile')):\n        os.remove(os.path.join(vagrantfile_path, 'Vagrantfile'))\n    if os.path.exists(vagrantfile_path):\n        os.rmdir(vagrantfile_path)","lang":"python","description":"This quickstart demonstrates how to initialize `python-vagrant`, bring up a VM, check its status, and destroy it. It requires the Vagrant CLI tool to be installed and available in your system's PATH. A simple Vagrantfile is created for demonstration purposes if not already present."},"warnings":[{"fix":"Update calls to `up()` to explicitly pass `vm_name` as the first argument, or `None` if no specific VM name is desired, before other keyword arguments like `provision`.","message":"The `up()` method in version 1.0.0 changed its signature. The `vm_name` argument is now the first positional argument. If you were calling `up(provision=True)` you must now call `up(vm_name=None, provision=True)` or `up(None, provision=True)`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade your Python environment to Python 3.8 or newer.","message":"Version 1.0.0 dropped support for Python 3.7. The minimum required Python version is now 3.8.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Install Vagrant CLI from HashiCorp's official website (vagrantup.com) or your system's package manager before using `python-vagrant`.","message":"This library acts as a wrapper around the Vagrant CLI tool. It does NOT bundle Vagrant itself. You must have the Vagrant CLI installed on your system and available in your PATH for `python-vagrant` to function correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Plan to upgrade your Python environment to Python 3.9 or newer to ensure continued compatibility with `python-vagrant`.","message":"Support for Python 3.8 has been deprecated in the upcoming 1.1.0 release (already available on GitHub, but not yet PyPI at the time of writing). While it might still work, future versions will likely drop support.","severity":"deprecated","affected_versions":"Future versions (>=1.1.0)"},{"fix":"Ensure you are using the public API (e.g., `from vagrant import Vagrant`) and avoid relying on internal module paths.","message":"Version 1.0.0 adopted a `src` code layout. While this primarily affects packaging, users with non-standard import patterns or those directly accessing internal modules might need to adjust their paths.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}