Configure an interpreter using Vagrant
Last modified: 27 July 2022Professional feature: download PyCharm Professional to try.
tip
PyCharm implements the Vagrant functionality with a bundled plugin, which can be completely disabled by clearing the Vagrant checkbox on the Plugins page of the IDE settings Ctrl+Alt+S.
Ensure that the following prerequisites are met (outside of PyCharm):
Oracle's VirtualBox is installed on your computer.
Vagrant is installed on your computer, and all the necessary infrastructure is created.
The parent folders of the following executable files are added to the system
PATH
variable:vagrant.bat or vagrant from your Vagrant installation. This should be done automatically by the installer.
VBoxManage.exe or VBoxManage from your Oracle's VirtualBox installation.
The required virtual boxes are created.
Configure a remote Python interpreter
Ensure that you have downloaded and installed Python on your computer.
Ensure that you have properly initiated and started Vagrant. Basically, you need to open the Terminal window and execute the following commands:
$ vagrant init ubuntu/trusty64
and
$ vagrant up
See Vagrant documentation for more information.
Press Ctrl+Alt+S to open the IDE settings and select Plugins.
Install the Vagrant plugin.
Do one of the following:
Click the Python Interpreter selector and choose Add New Interpreter.
Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project: <project name> | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.
Select On Vagrant:
In the New Target: Vagrant dialog, click the browse icon
next to the Vagrant Instance Folder field, and specify the desired Vagrant instance folder.
This results in showing the link to Vagrant Host URL.
In the next field, PyCharm will display the path to the Python executable. Press "Next" to proceed.
You can create a virtual environment (venv or Conda) or use a system Python interpreter for the target Vagrant instance. Note that virtual environment must be configured and available in the specified Vagrant instance folder. Otherwise, the corresponding lists will be empty.
Press Create to complete the task.
You can go back in the Python Interpreter page, if necessary, and configure the path mappings:
Click
:
In the dialog that opens add
or delete
path mappings as desired.
Thanks for your feedback!