0

I have written the following .bat file:

start chrome http://127.0.0.1:8000/
venv\Scripts\activate
python manage.py runserver 8000

When I perform these steps myself, one by one, in prompt, it runs the server and opens the site perfectly.

However, when I use iexpress to convert this file to an .exe and run it, the site just displays the "unavailable" message, as if no server were running.

I'm not sure, but I think this is because the exe closes as soon as it's executed the commands, instead of keeping the server running. How do I fix this?

Themlethem
  • 21
  • 1
  • 3

1 Answers1

0

First of all, you dont need to activate venv in bat: Activate virtualenv and run .py script from .bat . What you need is to specify the path to your venv directory: {path to virtual environment directory}/Scripts/python.exe

Then, try to add pause to the end of your bat file. Then, if there is, please post errors in CMD promt to figure out what is happening

  • Thanks, the program launches now. However it led to another problem. The exe is run in local/temp instead of from where I called it. Which means that in .bat I need to put the full path to manage.py instead of a relative one, as I would like. On top of that, inside the program itself, it now can't find any of the relative paths either. How can I get it to run from the folder, as it does when I do it manually in commandprompt? – Themlethem Jan 11 '22 at 09:26