A Python script that activates the virtualenv and then runs another Python script?

ugavetheroses picture ugavetheroses · Jun 19, 2015 · Viewed 54.6k times · Source

On Windows Vista, I need a script that starts the activate (to activate the virtualenv) script in:

C:\Users\Admin\Desktop\venv\Scripts\

And later, in the virtual environment, starts to the manage.py runserver in the folder:

C:\Users\Admin\Desktop\helloworld\

How should I do? What modules should I use?

Answer

Ashish Gupta picture Ashish Gupta · Jun 19, 2015

You can activate your virtualenv and then start server using a bat file. Copy this script in to a file and save it with .bat extension (eg. runserver.bat)

@echo off
cmd /k "cd /d C:\Users\Admin\Desktop\venv\Scripts & activate & cd /d    C:\Users\Admin\Desktop\helloworld & python manage.py runserver"

Then you can just run this bat file (just double click) to start the server