Adding Python to your Project
devbox add [email protected]
, or in your devbox.json
add:
devbox search python
. You can also view the available versions on
Nixhub
Installing Packages with Pip
Example Repo pip is the standard package manager for Python. Since it installs python packages globally, we strongly recommend using a virtual environment. Thepython
package automatically comes bundled with pip
, and the python
plugin for Devbox will
automatically create a virtual environment for installing your packages locally
Your virtual environment is created in the .devbox/virtenv/python
directory by default, and can be
activated by running . $VENV_DIR/bin/activate
in your Devbox shell. You can activate the virtual
environment automatically using the init_hook of your devbox.json
:
For Fish or other shells, you may need to use a different activation script. See the venv
docs for more details.
.devbox/virtenv/python/.venv
by default. You can modify
this path by setting the VENV_DIR
environment variable in your devbox.json:
devbox add python3xxPackages.pip
,
where 3xx
is the major + minor version (e.g., python310 = python@3.10) of Python you want to
install:
Pipenv
Example Repo pipenv is a tool that will automatically set up a virtual environment for installing your PyPi packages. You can installpipenv
by adding it to the packages in your devbox.json
. You can then manage
your packages and virtual environment via a Pipfile
devbox shell
.
Poetry
Example Link Poetry is a packaging and dependency manager for Python that helps you manage your Python packages, and can automatically create a virtual environment for your project. You can install Poetry by adding it to the packages in yourdevbox.json
. You can then manage your
packages and virtual environment via a pyproject.toml
devbox shell
, and provide
you with access to all your packages.
Disabling the Python Plugin
If you would prefer to disable the Python Plugin, you can add python usingdevbox add python --disable_plugin
or in your devbox.json
: