PyCharm 2022.2 Help

Configure an interpreter using Vagrant

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

  1. Ensure that you have downloaded and installed Python on your computer.

  2. 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.

  3. Press Ctrl+Alt+S to open the IDE settings and select Plugins.

  4. Install the Vagrant plugin.

  5. 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.

  6. Select On Vagrant:

    Add a Vagrant interpreter
  7. In the New Target: Vagrant dialog, click the browse icon the Browse button next to the Vagrant Instance Folder field, and specify the desired Vagrant instance folder.

    This results in showing the link to Vagrant Host URL.

    Specifying the Vagrant instance folder
  8. In the next field, PyCharm will display the path to the Python executable. Press "Next" to proceed.

    Python executable is discovered
  9. 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.

    Virtual environment on a target Vagrant instance

    Press Create to complete the task.

  10. You can go back in the Python Interpreter page, if necessary, and configure the path mappings:

    1. Click the Browse button:

      Path mapping
    2. In the dialog that opens add Add a path mapping or delete Delete a path mapping path mappings as desired.

Last modified: 27 July 2022