Reputation: 41
I develop my own django-based project with pipenv. Couple days ago I created simple bash script to speed up boring stuff.
All time I run terminal, go to the same directory and execute pipenv shell
, after that I open up project in VScode code .
and started python manage.py runserver
for looking up my progress.
I try create script which do the same stuff but simplied, just run webber
and here go (it comes from /usr/local/bin).
But I have one problem of these, I can't keep my pipenv shell
running and execute python manage.py runserver
at the same time. I mean when I stop Ctrl+C python server I don't receive my virtual enviroment (this happed in bash script ~ normally work fine).
However, server is start up, so it's virtual env.
I tried with pipenv run
command but it doesn't get inside virtual env at all.
Script:
#!/bin/bash
cd ~/Documents/myprojects/Webber
code .
source $(pipenv --venv)/bin/activate
python manage.py runserver
My question is: How can I run command inside virtualenv in shell script and receive this subshell?
Upvotes: 4
Views: 2914
Reputation: 841
you can use the full path to the virtualenv folder instead of pipenv
command. For example, if you created the virtual environment in you home directory called venv-webber
:
source $HOME/venv-webber/bin/activate
Upvotes: 2