To install a specific version of a package, use the command pipenv install <package>~=1.2
.
How to use Pipenv to create virtual environments on Scaleway GPU Instances
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.
Before you start
To complete the actions presented below, you must have:
Requirements
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A GPU Instance
- An SSH key added to your account
Accessing the preinstalled Pipenv virtual environment
Refer to our dedicated documentation 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:
-
View installed packages and dependencies:
pipenv graph -
Install a new package:
pipenv install <package>Tip -
Uninstall a package:
pipenv uninstall <package> -
Update a package:
pipenv update <package>TipTo update all packages, simply run
pipenv update
.ImportantBe aware that installing and updating packages may cause conflicts with the existing virtual environment installation.
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.
-
View Pipfile contents:
cat PipfileThe Pipfile includes:
source
: Package sourcespackages
: Required packages for production and developmentdev-packages
: Required packages for development onlyrequires
: Required Python version
Packages installed with
pipenv install <package>
are added to the Pipfile. This allows others to install dependencies from the Pipfile withpipenv install
. -
View Pipfile.lock contents:
cat Pipfile.lockThe Pipfile.lock specifies package versions to prevent breaking changes from dependency upgrades.
Creating your own virtual environments
-
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. -
Exit the current virtual environment:
exit -
Navigate to the home directory:
cd ~ -
Create a new project directory and navigate into it:
mkdir my-proj && cd my-projTipTo 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.
-
Create a new virtual environment and generate a Pipfile:
pipenv install -
Activate the virtual environment:
pipenv shellYour prompt should indicate you are in the activated
my-proj
Pipenv virtual environment.
Going further
For more information, refer to the official Pipenv documentation.