1

When I try to run "django-admin help" or any other django-admin command in the vscode terminal (within the virtualenv) it gives me the following error :

Fatal error in launcher: Unable to create process using '"F:\DevOps\Django\btre_project\venv\Scripts\python.exe" "F:\Django\btre_project\venv\Scripts\django-admin.exe" help': The system cannot find the file specified.

The whole Django project was located in F:\DevOps first but then I moved the Django folder outside the F:\DevOps so it's now at this location currently "F:\Django".

Virtual environment can be activated and deactivated perfectly and also if I start the server with "python manage.py runserver" The server is up and running. But whenever I try to run the django command it gives me the above error.

Also, in the virtual environment of project django is installed and I also tried reinstalling the django in the virtualenv with pip but nothing worked out and I get the same error.

Any help would be appreciated, thanks.

haroon khan
  • 51
  • 2
  • 8
  • Does this answer your question? [Can I move a virtualenv?](https://stackoverflow.com/questions/32407365/can-i-move-a-virtualenv) – Abdul Aziz Barkat May 31 '22 at 16:50
  • No it doesn't . my virtual environment is working fine. like it can be activated and deactivated but the django commands give the error. – haroon khan May 31 '22 at 20:09
  • If you read the above linked question carefully the virtual environment's `activate` scripts etc. have the path of the virtual environment hardcoded, they set that as an env var for the current session. That is how `django-admin.exe` knows which python to use and also the reason you get the error. – Abdul Aziz Barkat Jun 01 '22 at 03:15

1 Answers1

0

The easiest way to handle this is to create a new virtual environment, pip install django in that environment and it will resolve this specific issue.

PS: Then run your manage.py server on this new virtual environment instead of the old one!

haroon khan
  • 51
  • 2
  • 8