简体   繁体   English

Django:每次我开发 django 应用程序时都必须打开虚拟环境吗

[英]Django: Does the virtual environment have to be on every time i develop my django app

i have installed and set up the virtual environment using the command line.我已经使用命令行安装并设置了虚拟环境。 i am using pycharm to develop my django application.我正在使用 pycharm 来开发我的 django 应用程序。 so that was day 1. On day 2 when i put my laptop back on to go back to working on my django application do i need to go back to command line and type in workon 'virtualenvironment-name' or can i just develop the django app without switching on the virtual environment. so that was day 1. On day 2 when i put my laptop back on to go back to working on my django application do i need to go back to command line and type in workon 'virtualenvironment-name' or can i just develop the django应用程序无需打开虚拟环境。

First you need to have a clear idea what a virtual environment does.首先,您需要清楚地了解virtual environment的作用。

The one and only thing virtual enviornment does is it isolates projects dependencies.虚拟环境所做的唯一一件事就是隔离项目的依赖关系。 You can definitely work without virtual environment.您绝对可以在没有虚拟环境的情况下工作。 All you need to do is just install the libraries globally.您需要做的只是全局安装这些库。 That's it.而已。

EDIT编辑

Installing packages globally is not recomended because when you use virtual environment,不推荐全局安装包,因为当你使用虚拟环境时,

  1. Managing project packages is easier管理项目包更容易
  2. Resolving package version issues is much easier解决 package 版本问题更容易

Moreover, you should maintain a proper requirements.txt file when working with virtual environements because a single package might crash your entire code base.此外,在使用虚拟环境时,您应该维护一个适当的requirements.txt文件,因为单个 package 可能会使您的整个代码库崩溃。 In that case you can totally delete the virtual environment and again start fresh.在这种情况下,您可以完全删除虚拟环境并重新开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每次我重新启动我的vscode Django时是否需要激活Django虚拟环境 - Is it necessary to activate Django Virtual Environment every time i restart my vscode Django 我无法在我的虚拟环境中安装 Django - I cannot install Django in my Virtual Environment 如何在虚拟环境中移动完成的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? 首先创建Django应用程序或虚拟环境? - Create the Django app or the virtual environment first? 在新的虚拟环境中运行旧的django应用 - Running old django app in new virtual environment Django-我有一个具有简单视图的简单应用程序-为什么每个URL请求都会调用两次? - Django - I have a simple app with a simple view - why does it get called twice for every url request? 我是否正确组织了我的django应用程序? - Have I organised my django app correctly? 我的 Django 帐户应用程序出现错误 - I have an error in my Django accounts app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM