Operations 8 min read

Speed Up Onboarding: Build Python Development Environments with Vagrant

Learn how to quickly provision a consistent Python development environment using Vagrant and VirtualBox, from installing the tools, configuring a Vagrantfile, syncing project directories, installing dependencies, to exporting the box for sharing, eliminating manual setup and onboarding delays.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Speed Up Onboarding: Build Python Development Environments with Vagrant

New developers often waste time manually configuring development environments, which is error‑prone and repetitive. Vagrant, a virtual‑machine orchestration tool, solves this by allowing a single, shareable configuration that creates isolated, reproducible environments.

Installation

On macOS, install VirtualBox and Vagrant with two Homebrew commands:

brew cask install virtualbox
brew cask install vagrant

Verify the installation:

$ vagrant version
Installed Version: 2.2.5
Latest Version: 2.2.5
You're running an up-to-date version of Vagrant!

Initialize Environment

Add a base box (CentOS 7) either by downloading from the public repository or by specifying a local file: vagrant box add --provider virtualbox centos/7 Or with a local path:

vagrant box add --name centos/7 --provider virtualbox /Users/pzqu/Documents/code/test/vbox/centos_virtualbox.box

Initialize the project directory:

cd /Users/pzqu/Documents/code/test/vbox
vagrant init centos/7

This creates a Vagrantfile that defines the VM configuration. A simple example that mounts the host project directory to /data/code inside the VM looks like:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.synced_folder "/Users/pzqu/Documents/code/gerrit", "/data/code"
end

If the shared folder fails, install the vagrant-vbguest plugin:

vagrant plugin install vagrant-vbguest

Build Development Environment

Start the VM and SSH into it:

vagrant up
vagrant ssh

Inside the VM, install the Python dependencies defined in requirements.txt: pip install -r requirements.txt You can generate requirements.txt from the current environment with pip freeze > requirements.txt.

Configure PyCharm

In PyCharm, add the Vagrant plugin, then configure a new Python interpreter pointing to the VM’s Python executable (e.g., /data/code is the synced project path). Set the interpreter and working directory to the paths inside the VM.

Vagrant logo
Vagrant logo
Shared folder error screenshot
Shared folder error screenshot
PyCharm Vagrant plugin configuration
PyCharm Vagrant plugin configuration

Export Box for Others

List the running VMs:

$ vboxmanage list vms
"vbox_default_1563884434349_3918" {59864f0b-9731-4839-baa2-95d9a6aab731}

Package the VM into a reusable box file:

vagrant package --base vbox_default_1563884434349_3918 --output centos7_hanah_environment.box

Distribute the .box file and add it on another machine with:

vagrant box add centos7_hanah_environment ./centos7_hanah_environment.box

Other Thoughts

Vagrant and Docker overlap in providing reproducible environments, but they differ fundamentally: Vagrant orchestrates full virtual machines (requiring VirtualBox or another hypervisor) and excels at bulk VM management, while Docker uses container‑level virtualization for faster, lighter builds. Both have their place in modern DevOps workflows.

Vagrant vs Docker comparison diagram
Vagrant vs Docker comparison diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonDevOpsEnvironment provisioningVirtualBoxVagrant
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.