# Terminals and ! commands in JupyterHub not using virtualenv Python

**URL:** <https://discourse.jupyter.org/t/terminals-and-commands-in-jupyterhub-not-using-virtualenv-python/37722>\
**Category:** JupyterHub\
**Tags:** jupyterhub, how-to, help-wanted\
**Created:** [August 19, 2025, 6:23pm UTC](https://discourse.jupyter.org/t/terminals-and-commands-in-jupyterhub-not-using-virtualenv-python/37722 "2025-08-19T18:23:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)\
**Post date:** [August 19, 2025, 10:25pm UTC](https://discourse.jupyter.org/t/terminals-and-commands-in-jupyterhub-not-using-virtualenv-python/37722/2 "2025-08-19T22:25:17Z")

</div>

Can you check if your c.Spawner.environment config is having _any_ effect? e.g. setting `“TESTVARIABLE”: “TESTVALUE”`? It could be that the config isn’t being loaded, or is being overridden by some later config. Check the value of $VIRTUAL\_ENV and $PATH.

For the most part, I would expect your config to work, so I expect something is getting a little wonky

If you want a virtualenv to be truly fully activated, including whatever setup scripts, you’re right that `c.LocalProcessSpawner.shell_cmd` could be part of it. For such things, I usually use the `c.Spawner.cmd` [approach](https://discourse.jupyter.org/t/jupyter-server-source-script-on-launch/15372/3), where you write a shell script that does activation, etc. (maybe even `bash -l`), then always ends with `exec jupyterhub-singleuser "$@"`:

```auto
#!/bin/bash -l
# ^login shell means source everything in profile.d, bash_profile, etc.

# activate the project env
source /usr/src/myproject/.venv/bin/activate

# finally, 'become' jupyterhub-singleuser
exec jupyterhub-singleuser "$@"

```

---

_[View the full topic](https://discourse.jupyter.org/t/terminals-and-commands-in-jupyterhub-not-using-virtualenv-python/37722)._
