Activate Python virtualenv in current shell #1785
-
Hi ! :) Here is my use case: when I start working on a python project, I want to type Something that would looks like this: # I create a project's virtualenv at some point
cd my_project
python -m venv env
# when I start working on "my_project"
cd my_project
just dev
# The project virtualenv is activated
(env) user@user:~/my_project$ echo "i can start working" Without using But using these commands as a just recipe does not work. dev:
. env/bin/activate
# leads to ==> sh: 1: source: not found
dev:
source env/bin/activate
# leads to ==> the recipe is executed successfully, but the virtualenv is not activated in my working shell Did you manage to activate a virtualenv in your recipes ? Thanks in advance and have a nice day 🎅 PS: PS2: Thanks for making just, it's a pleasure to use :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Currently, there isn't a good way to do this. Each recipe line runs in a new shell, so environment variables loaded in one line don't propagate to the next. You can use a shebang recipe, which runs as a script, to get around this: dev:
#!/usr/bin/env bash
source env/bin/activate |
Beta Was this translation helpful? Give feedback.
Currently, there isn't a good way to do this. Each recipe line runs in a new shell, so environment variables loaded in one line don't propagate to the next.
You can use a shebang recipe, which runs as a script, to get around this: