1

Is it necessary to activate the virtual environment? How can we re-enter/re-activate the already existing environment in Django? I shut down my computer and when I reopen the vs code the the '(venv)' mark is not there in the terminal before the locationenter image description here

Also is this the reason why I am getting the error ImportError: cannot import name 'static' from 'django.conf'

3 Answers3

1

Yes it is necessary to activate the virtual environment

by activating your virtual environment the packages you install with pip will install in your virtual environment not your system global python

by installing python extension on your vscode you can select your python interpreter to activate your virtual environment everytime you open vscode terminals

to do that first install that extension then press ctrl + shift + p and type

Python: Select Interpreter
Mahdi mehrabi
  • 1,486
  • 2
  • 18
  • 21
0

You can select the python interpreter at the button left of vscode. To find that path, you can find the folder to ur venv and look for the pythonw.exe in the Scripts folder.

0

Yes you have to. Open a new bash terminal and enter the command: xxxx/Scripts/activate.bat

where xxx is the folder wherein the initial virtual environment was created in.

After that, be sure to check that the terminal displays (xxx) before the bash prompt $.

For completeness, kindly open another terminal. This works for me on vscode.