---
title: How to use Pipenv to create virtual environments on Scaleway GPU Instances
description: Learn how to use Pipenv to create and manage virtual environments for your Python projects on Scaleway GPU Instances.
tags: Pipenv virtual environment GPU Python
dates:
  validation: 2025-07-28
  posted: 2022-03-25
---
import Requirements from '@macros/iam/requirements.mdx'


Pipenv is a powerful package and dependency manager for Python projects. It combines the functionalities of several tools:

- **pip** for managing Python packages
- **pyenv** for managing Python versions
- **Virtualenv** for creating isolated Python environments
- **Pipfile** for managing project dependencies

**Pipenv is preinstalled on all Scaleway AI Docker images for GPU Instances.** When you launch one of these Docker images, you are placed in an activated Pipenv virtual environment with preinstalled packages and tools. You can also create your own virtual environments using Pipenv.

<Requirements />

### Requirements

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- A [GPU Instance](/gpu/how-to/create-manage-gpu-instance/)
- An [SSH key](/organizations-and-projects/how-to/create-ssh-key/) added to your account

## Accessing the preinstalled Pipenv virtual environment

Refer to our [dedicated documentation](/gpu/how-to/use-preinstalled-env/#working-with-the-preinstalled-environment-on-ubuntu-focal-gpu-os-12) on how to access the Pipenv virtual environment from your Scaleway GPU Instance.

## Managing packages with Pipenv

You can view, install, uninstall, and update packages using simple `pipenv` commands:

1. View installed packages and dependencies:

    ```bash
    pipenv graph
    ```

2. Install a new package:

    ```bash
    pipenv install <package>
    ```

    <Message type="tip">
      To install a specific version of a package, use the command `pipenv install <package>~=1.2`.
    </Message>

3. Uninstall a package:

    ```bash
    pipenv uninstall <package>
    ```

4. Update a package:

    ```bash
    pipenv update <package>
    ```

    <Message type="tip">
      To update all packages, simply run `pipenv update`.
    </Message>

    <Message type="important">
      Be aware that installing and updating packages may cause conflicts with the existing virtual environment installation.
    </Message>

## Understanding Pipfiles

Each Pipenv virtual environment has a Pipfile that details project dependencies, replacing the typical `requirements.txt` file. When you create a Pipenv environment, a Pipfile is automatically generated.

1. View Pipfile contents:

    ```bash
    cat Pipfile
    ```

    The Pipfile includes:
    - `source`: Package sources
    - `packages`: Required packages for production and development
    - `dev-packages`: Required packages for development only
    - `requires`: Required Python version

    Packages installed with `pipenv install <package>` are added to the Pipfile. This allows others to install dependencies from the Pipfile with `pipenv install`.

2. View Pipfile.lock contents:

    ```bash
    cat Pipfile.lock
    ```

    The Pipfile.lock specifies package versions to prevent breaking changes from dependency upgrades.

## Creating your own virtual environments

1. Connect to your GPU Instance via SSH and launch a Scaleway AI Docker container.

    You will be in the `~/ai` directory with the virtual environment activated.

2. Exit the current virtual environment:

    ```bash
    exit
    ```

3. Navigate to the home directory:

    ```bash
    cd ~
    ```

4. Create a new project directory and navigate into it:

    ```bash
    mkdir my-proj && cd my-proj
    ```

    <Message type="tip">
      To avoid losing your virtual environment upon exiting the container, create this folder in a directory [mapped to one of your GPU Instance's local volumes](/gpu/how-to/use-gpu-with-docker#how-to-map-local-volumes).
    </Message>

5. Create a new virtual environment and generate a Pipfile:

    ```bash
    pipenv install
    ```

6. Activate the virtual environment:

    ```bash
    pipenv shell
    ```

    Your prompt should indicate you are in the activated `my-proj` Pipenv virtual environment.

## Going further

For more information, refer to the [official Pipenv documentation](https://docs.pipenv.org/).