简体   繁体   English

为什么我需要为公共Django应用程序创建虚拟环境?

[英]Why do I need to create a virtual environment for my public Django application?

I've been running my Django project (website) in my local virtual environment. 我一直在本地虚拟环境中运行Django项目(网站)。 However I now want to go live and make the website public - so I've created my remote server on Digital Ocean, and have been following it's tutorial on settings up Django. 但是,我现在想上线并使该网站公开-因此,我在Digital Ocean上创建了我的远程服务器,并一直遵循有关设置Django的教程。 However I've reached this point in the tutorial where it says to create a virtual environment . 但是,在本教程中,我已经达到了创建虚拟环境的目的 I thought virtual environments were only used for testing your application offline? 我以为虚拟环境仅用于离线测试您的应用程序? Why do I need a virtual environment for my application running on a remote server? 为什么在运行在远程服务器上的应用程序需要虚拟环境?

I'm not really familiar with Digital Ocean, but creating a virtualenv should not be strictly required. 我对Digital Ocean并不是很熟悉,但是严格要求不要创建virtualenv

It is still a good idea and I'd recommend doing it though. 这仍然是一个好主意,不过我还是建议您这样做。

It will prevent packages required for your application that you install to your virtual environment from messing up other Python applications requirements. 这将防止您安装到虚拟环境的应用程序所需的软件包破坏其他Python应用程序的要求。

For example, let's say your application requires coolpackage 0.9.12 , and another application requires coolpackage 1.1.6 . 例如,假设您的应用程序需要coolpackage 0.9.12 ,而另一个应用程序需要coolpackage 1.1.6 If there are breaking changes going from 0.9.12 to 1.1.6 , installing coolpackage 1.1.6 will break your first application. 如果从0.9.121.1.6进行了重大更改,则安装coolpackage 1.1.6将破坏您的第一个应用程序。

Also, keep in mind that some functionality of your operating system might require specific versions of Python packages (which might even have been installed by some other means than pip ) that you could break in this way. 另外,请记住,操作系统的某些功能可能需要特定版本的Python软件包(甚至可能通过pip以外的其他方式安装了),您可能会用这种方式破坏它们。

暂无
暂无

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

相关问题 我无法在我的虚拟环境中安装 Django - I cannot install Django in my Virtual Environment 如何在虚拟环境中找到我的Django安装? - How do I find my Django install within my virtual environment? 我是否需要在我的机器上安装 Python 才能在虚拟环境中运行代码? - Do I need to have Python installed on my machine to run a code in a virtual environment? 为什么我在为我的 Django 项目激活虚拟环境后使用“python manage.py runserver”命令时,我的 CMD 提示不执行任何操作 - Why does my CMD prompt do nothing when I use the “python manage.py runserver” command after activating the virtual environment for my Django project 如何修复在我的虚拟环境之外所做的 Django 更改? - How do I fix Django changes made outside of my virtual environment? 当我的机器中已经有 MySQL 时,我还需要在 Django 虚拟环境中安装 MySQL 吗? - Do I still need to install MySQL in Django virtual env while I already have MySQL in my machine? 使用venv时是否需要激活虚拟环境 - Do I need to activate virtual environment when using venv 每次在python虚拟环境中都需要安装软件包吗? - do I need to install packages every time in python 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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM