meta | content | tags | dates | categories | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Pipenv, virtual environment, GPU, Python |
|
|
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.
- 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
Refer to our dedicated documentation on how to access the Pipenv virtual environment from your Scaleway GPU Instance.
You can view, install, uninstall, and update packages using simple pipenv
commands:
-
View installed packages and dependencies:
pipenv graph
-
Install a new package:
To install a specific version of a package, use the command `pipenv install ~=1.2`.pipenv install <package>
-
Uninstall a package:
pipenv uninstall <package>
-
Update a package:
To update all packages, simply run `pipenv update`. Be aware that installing and updating packages may cause conflicts with the existing virtual environment installation.pipenv update <package>
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 Pipfile
The 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.lock
The Pipfile.lock specifies package versions to prevent breaking changes from dependency upgrades.
-
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:
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).mkdir my-proj && cd my-proj
-
Create a new virtual environment and generate a Pipfile:
pipenv install
-
Activate the virtual environment:
pipenv shell
Your prompt should indicate you are in the activated
my-proj
Pipenv virtual environment.
For more information, refer to the official Pipenv documentation.