---
sidebar_label: Install custom Python virtual environments
---

If `DH_DND_PYTHON` is set to `true` in your [`cluster.cnf`](../installation/cluster-config-guide.md) file, then a [default Python virtual environment](../../user-guide/python-environment.md) is configured for Core+ workers. You can also create alternative Python virtual environments and assign them to your own custom worker kinds.

To install a Python environment for the Core+ worker, you must create a virtual environment and configure it properly for the installed Community version. Deephaven recommends placing them in `/usr/illumon/coreplus/venv/`.

In the following example, we create a default virtual environment in the `/usr/illumon/coreplus/venv/VAR::COREPLUS_DHC_VERSION-custom` directory. The `requirements.txt` file provides a list of packages and versions that Deephaven has tested with this distribution. You should use it as a starting point for adding, removing, or replacing packages. Deephaven does not test integrations with package versions other than those listed in `requirements.txt`.

In addition to the `requirements.txt` file (which references packages available via `pip`), you must also install the Deephaven Core+ worker wheel. It is recommended that you also install the Deephaven Core+ client wheel.

> [!NOTE]
> In the snippets below, be sure to change the path to match your Core+ install and select the proper Community `pip` package version.

The following snippet installs a custom Python virtual environment with `pip`:

```bash
# Replace the paths below where you wish to a) install the virtual environment,
# b) take the requirements.txt file (which specifies Python dependencies) from,
# and c) source the appropriate Enterprise Core+ wheels.
#
# While not required, Deephaven recommends that you install the virtual environment
# inside the Core+ package directory for each specific version.
venvPath=/usr/illumon/coreplus/venv/VAR::COREPLUS_DHC_VERSION-custom
sudo -u irisadmin python3.10 -m venv $venvPath
sudo -u irisadmin /bin/bash -c "source $venvPath/bin/activate && \
pip3.10 install -r /usr/illumon/coreplus/latest/py/resources/requirements.txt && \
pip3.10 install /usr/illumon/coreplus/latest/py/wheel/deephaven_coreplus_worker-VAR::COREPLUS_DHE_VERSION-py3-none-any.whl && \
pip3.10 install /usr/illumon/coreplus/latest/py/wheel/deephaven_coreplus_client-VAR::COREPLUS_DHE_VERSION-py3-none-any.whl"
```

If, instead, you prefer to use `conda`, refer to the snippet below to install a custom Python virtual environment:

```bash
export PYTHONNOUSERSITE=True
conda create --prefix /usr/illumon/coreplus/venv/corePlusConda python=3.10
conda activate /usr/illumon/coreplus/venv/corePlusConda
/usr/illumon/coreplus/venv/corePlusConda/bin/pip3 install -r /usr/illumon/coreplus/latest/py/resources/requirements.txt
/usr/illumon/coreplus/venv/corePlusConda/bin/pip3 install /usr/illumon/coreplus/latest/py/wheel/deephaven_coreplus_worker-VAR::COREPLUS_DHE_VERSION-py3-none-any.whl
/usr/illumon/coreplus/venv/corePlusConda/bin/pip3 install /usr/illumon/coreplus/latest/py/wheel/deephaven_coreplus_client-VAR::COREPLUS_DHE_VERSION-py3-none-any.whl
```

You must create the virtual environment on each query server.

## Related documentation

- [Python environment](../../user-guide/python-environment.md)
- [Code Studio](../../interfaces/web/code-studio.md)
- [Query Monitor](../../interfaces/web/query-monitor.md)
- [`venv` Pydoc](https://docs.deephaven.io/pycoreplus/20240517/worker/code/deephaven_enterprise.venv.html#module-deephaven_enterprise.venv)
