[英]How do I figure out what dependencies to install when I copy my Django app from one system to another?
I'm using Django and Python 3.7. 我正在使用Django和Python 3.7。 I want to write a script to help me easily migrate my application from my local machien (a Mac High Sierra) to a CentOS Linux instance.
我想编写一个脚本来帮助我轻松地将应用程序从本地机器(Mac High Sierra)迁移到CentOS Linux实例。 I'm using a virtual environment in both places.
我在两个地方都使用虚拟环境。 There are many things that need to be done here, but to keep the question specific, how do I determine on my remote machine (where I'm deploying my project to), what dependencies are lacking?
这里有很多事情需要做,但是要保持特定的问题,如何确定我的远程机器(将项目部署到的地方)上缺少什么依赖项? I'm using rsync to copy the files (minus the virtual environment)
我正在使用rsync复制文件(减去虚拟环境)
On the source system execute pip freeze > requirements.txt
, then copy the requiremnts.txt
to the target system and then on the target system install all the dependencies with pip install -r requirements.txt
. 在源系统上,执行
pip freeze > requirements.txt
,然后将requiremnts.txt
复制到目标系统,然后在目标系统上使用pip install -r requirements.txt
安装所有依赖项。 Of course you will need to activate the virtual environments on both systems before execute the pip
commands. 当然,在执行
pip
命令之前,您将需要在两个系统上都激活虚拟环境。
If you are using a source code management system like git
it is a good idea to keep the requirements.txt
up to date in your source code repository. 如果您使用的是
git
之类的源代码管理系统,则最好在您的源代码存储库中保持requirements.txt
为最新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.