[英]Is it necessary to activate Django Virtual Environment every time i restart my vscode Django
Is it necessary to activate the virtual environment?是否需要激活虚拟环境? How can we re-enter/re-activate the already existing environment in Django?我们如何重新进入/重新激活 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 location enter image description here我关闭了计算机,当我重新打开 vs 代码时,终端中没有“(venv)”标记,然后在此处输入图像描述的位置
Also is this the reason why I am getting the error ImportError: cannot import name 'static' from 'django.conf'这也是我收到错误 ImportError: cannot import name 'static' from 'django.conf' 的原因
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通过激活您的虚拟环境,您使用pip安装的软件包将安装在您的虚拟环境中,而不是您的系统全局 python
by installing python extension on your vscode you can select your python interpreter to activate your virtual environment everytime you open vscode terminals通过在你的 vscode 上安装python 扩展,你可以选择你的 python 解释器来激活你每次打开 vscode 终端时的虚拟环境
to do that first install that extension then press ctrl + shift + p and type要做到这一点,首先安装该扩展,然后按ctrl + shift + p并键入
Python: Select Interpreter
You can select the python interpreter at the button left of vscode.可以在vscode左边的按钮选择python解释器。 To find that path, you can find the folder to ur venv and look for the pythonw.exe in the Scripts folder.要找到该路径,您可以找到 venv 的文件夹并在 Scripts 文件夹中查找 pythonw.exe。
Yes you have to.是的,你必须。 Open a new bash terminal and enter the command: xxxx/Scripts/activate.bat打开一个新的bash终端并输入命令:xxxx/Scripts/activate.bat
where xxx is the folder wherein the initial virtual environment was created in.其中 xxx 是创建初始虚拟环境的文件夹。
After that, be sure to check that the terminal displays (xxx) before the bash prompt $.之后,一定要检查bash提示符$之前终端是否显示(xxx)。
For completeness, kindly open another terminal.为了完整起见,请打开另一个终端。 This works for me on vscode.这在 vscode 上对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.