# Configuring Pipenv Environment

Pipenv is a tool that provides all necessary means to create a virtual environment for your Python project. It automatically  manages project packages through the `Pipfile` file as you install or uninstall packages.

Pipenv also generates the `Pipfile.lock` file, which is used to produce deterministic builds and create a snapshot of your working environment. This might be particularly helpful for security-sensitive deployment when project requirements and packages versions are critical. For more information about pipenv, refer to the project documentation at [pipenv.pypa.io](https://pipenv.pypa.io/en/latest/).

To use pipenv with CLion, you need to implement several preparation steps.

Procedure: Install pipenv

1. Run the following command to ensure you have pip installed in your system:

`$ pip --version`

You should expect to receive a system response indicating the pip version. If no pip is discovered, install it as described in the [Installation Instructions](https://pip.pypa.io/en/stable/installing/). Alternatively, you can download and install Python from [http://python.org](http://python.org).

2. Install `pipenv` by running the following command:

`$ pip install --user pipenv`

When the installation completes, you will see the following message:

![System response on successful pipenv installation](https://resources.jetbrains.com.cn/help/img/idea/2026.2/py_pipenv_install.png)

3. For your convenience, you might add the user base’s binary directory to your `PATH` environmental variable. If you skip this procedure, CLion will prompt you to specify the path to the pipenv executable when adding a pipenv environment.

Windows:

Procedure:

1. Run the following command:

`$ py -m site --user-site`

A sample output can be:

`C:\Users\jetbrains\AppData\Roaming\Python\Python37\site-packages`

2. Replace `site-packages` with `Scripts` in this path to receive a string for adding to the `PATH` variable, for example:

`$ setx PATH "%PATH%;C:\Users\jetbrains\AppData\Roaming\Python\Python37\Scripts"`

> **Warning:**
> Running the above command in PowerShell will overwrite the user PATH variable. To avoid that, use `$ setx PATH "$env:PATH;C:\Users\jetbrains\AppData\Roaming\Python\Python37\Scripts"` instead.
>
>
>
> However, you should keep in mind that this command has a side effect of duplicating the content of the system PATH variable in the user PATH variable.
>
>
>
> For more information about managing environment variables in PowerShell, refer to the [PowerShell documentation](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.3).

Linux and macOS:

Procedure:

1. Run the following command to find the user base's binary directory:

`$ python -m site --user-base`

An example of output can be

`/Users/jetbrains/.local` (macOS) or `/home/jetbrains/.local` (Linux)

2. Add `bin` to this path to receive a string for adding to the `~/.bashrc` file, for example:

`$ export PATH="$PATH:/Users/jetbrains/.local/bin"`

3. Run the following command to make the changes effective:

`$ source ~/.bashrc`

4. Ensure you have enabled bashrc in your `bash_profile`.

At any time you can alter the specified path to the pipenv executable in the project settings.   In the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))), navigate to `Tools | Python Integrated Tools`, and type the target path in the Path to Pipenv executable field.

After the preparation steps are done, you can use pipenv to create a virtual environment for new or existing projects.

Procedure: Set pipenv for a new Python project

1. In the left-hand pane of the Add Python Interpreter dialog, select Pipenv Environment.

![creating Pipenv environment](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_pipenv_settings.png)

2. If you have added the user base binary directory to your `PATH` environment variable, you don't need to set any additional options: the path to the pipenv executable will be autodetected.

3. If you don't have the base binary directory in `PATH`, CLion shows an error message: Pipenv executable is not found. Enter the executable path in the Pipenv executable field, for example: `C:\Users\jetbrains\AppData\Roaming\Python\Python37\Scripts\pipenv.exe` (Windows) or `/Users/jetbrains/.local/bin/pipenv` (macOS).

Click OK to save the changes and complete the task.

Procedure: Configure pipenv for an existing Python project

1. Select Pipenv Environment from the list of environment types.

![Adding a Pipenv environment](https://resources.jetbrains.com.cn/help/img/idea/2026.2/py_pipenv_add.png)

2. Choose the base interpreter from the list, or click ![Choose the base interpreter](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.inline.browse.svg) and find the Python executable in your file system.

3. If your project contains `Pipfile`, you can choose whether you want to install the packages listed in it by enabling or disabling the Install packages from Pipfile checkbox. By default, the checkbox is enabled.

4. If you have added the base binary directory to your `PATH` environmental variable, you do not need to set any additional options: the path to the pipenv executable will be autodetected.

If the pipenv executable is not found, follow the [pipenv installation procedure](#executable-path) to discover the executable path and then specify it in the dialog.

5. Click OK to complete the task.

> **Note:**
> CLion supports environment variables, for example, `PIPENV_VENV_IN_PROJECT`. You can add `PIPENV_VENV_IN_PROJECT=true` to your `~/.profile`, or `~/.bash_profile` or `~/.bashrc` and re-login to your OS in order for all the GUI processes to inherit new environment variables from your shell config.

## See also

### External Links

[Pipenv](https://pipenv.pypa.io/en/latest/)

