如何使用 virtualenv 部署具有依赖项的 python webapp? [英] How to deploy a python webapp with dependencies using virtualenv?
问题描述
我正在寻找一种方法来自动将用 Python 编写的 Web 应用程序部署到服务器.我想使用 virtualenv 为这个应用程序提供一个干净的环境.
但是,我想知道如何在部署到服务器时管理依赖项?
在开发中,我有一个 virtualenv,我在其中使用 pip 安装外部库,所以我正在寻找一种在生产中自动安装这些依赖项的方法?>
感谢您的时间
使用 pip 您可以创建需求文件:
$ pip freeze >要求.txt
然后在服务器上安装所有这些你做的:
$ pip install -r requirements.txt
这样(如果服务器拥有构建您可能包含的二进制包所需的一切)一切就绪.
I'm looking for a way to automate deployment of web applications written in Python to a server. I would like to use virtualenv to have a clean environment for this application.
However, I am wondering how to manage dependencies when deploying to the server ?
In development, I have a virtualenv in which I install external libraries using pip, so I am looking for a way to automatically install those dependencies in production ?
Thank you for your time
With pip you can create a requirements file:
$ pip freeze > requirements.txt
Then in the server to install all of these you do:
$ pip install -r requirements.txt
And with this (if the server has everything necessary to build the binary packages that you might have included) all is ready.
这篇关于如何使用 virtualenv 部署具有依赖项的 python webapp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!