[Django]-How to run django server with ACTIVATED virtualenv using batch file (.bat)

10👍

Found my solution by encoding this:

@echo off
cmd /k "cd /d C:\path\to\your\env\scripts & activate & cd /d C:\path\to\your\env\[projectname] & python manage.py runserver"

5👍

Call the activate.bat script in your batch file, before you run manage.py,

CALL \path\to\env\Scripts\activate.bat
python manage.py runserver

1👍

try \path\to\env\Scripts\activate

and look at virtualenv docs

0👍

If your virtualenv is created via virtualenvwrapper:

workon yourenvname & python manage.py runserver

0👍

I had to use absolute path to python in order to run "manage.py".

cmd /k "cd /d C:\path\to\project\.venv\Scripts & activate & python C:\path\to\project\manage.py runserver"

where & activate runs C:\path\to\project\.venv\Scripts\activate.bat
and & python runs python at C:\path\to\project\.venv\Scripts\python

you get the same result with:

call "C:\path\to\project\.venv\Scripts\activate.bat"
C:\path\to\project\.venv\Scripts\python "C:\path\to\project\manage.py" runserver

I guess my problem is that i have many pythons installed

👤Erd

Leave a comment