简体   繁体   English

每次我重新启动我的vscode Django时是否需要激活Django虚拟环境

[英]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.

相关问题 Django:每次我开发 django 应用程序时都必须打开虚拟环境吗 - Django: Does the virtual environment have to be on every time i develop my django app 如何在 DJango 中激活虚拟环境 - How to activate Virtual Environment in DJango 如何使用 Python 为 Windows 激活 Django 中的虚拟环境? - How to activate virtual environment in Django for Windows with Python? 我无法在我的虚拟环境中安装 Django - I cannot install Django in my Virtual Environment vscode 似乎没有激活我的虚拟 python 环境 - vscode doesn't seem to activate my virtual python environment 我正在处理一个 django 项目,无论何时我激活虚拟环境,服务器都不会运行 - I'm working on a django project and anytime i activate the virtual environment the server will not run 如何在 django 项目上工作时激活虚拟环境? - How to activate virtual environment while working on django project? 如何在虚拟环境中移动完成的Django项目? - How should I move my completed Django Project in a Virtual Environment? 我是否应该在新的 Django 虚拟环境中重新开始我的项目 - Should I start over my project in a new Django Virtual Environment 每次我为我的虚拟环境安装 django 时,我最终都会在全球范围内安装它。 如何仅为虚拟环境安装 django? - Everytime I install django for my virtual environment I end up installing it globally. How to install django for virtual environment only?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM