Back to Devbox

Python

examples/development/python/pipenv/README.md

0.17.21.3 KB
Original Source

Python

Python by default will attempt to install your packages globally, or in the Nix Store (which it does not have permissions to modify). To use Python with Devbox, we recommend setting up a Virtual Environment using pipenv or Poetry (see below).

Example Repo

Adding Python to your Project

devbox add [email protected], or in your devbox.json add:

json
  "packages": [
    "[email protected]"
  ],

This will install Python 3.10 in your shell. You can find other versions of Python by running devbox search python. You can also view the available versions on Nixhub

Pipenv

Example Repo

pipenv is a tool that will automatically set up a virtual environment for installing your PyPi packages.

You can install pipenv by adding it to the packages in your devbox.json. You can then manage your packages and virtual environment via a Pipfile

json
{
    "packages": [
        "python310",
        "pipenv"
    ],
    "shell": {
        "init_hook": "pipenv shell"
    }
}

This init_hook will automatically start your virtualenv when you run devbox shell.