本文介绍了在heroku flask webapp部署中requirements.txt vs Pipfile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Flask 网络应用程序部署到 Heroku,但我看到了关于需要在 git 存储库中包含哪些文件的相互矛盾的信息.

I'm trying to deploy a Flask webapp to Heroku and I have seen conflicting information as to which files I need to include in the git repository.

我的 web 应用程序是在虚拟环境 (venv) 中构建的,所以我有一个 Pipfile 和一个 Pipfile.lock.我还需要 requirements.txt 吗?一个会取代另一个吗?

My webapp is built within a virtual environment (venv), so I have a Pipfile and a Pipfile.lock. Do I also need a requirements.txt? Will one supersede the other?

我的另一个相关问题是,如果某个包在虚拟环境中安装失败会发生什么:我可以手动将它添加到 requirements.txtPipfile?这会有效地做与 pipenv install ... 相同的事情,还是做其他事情而不是将包添加到需求列表中(考虑到 Heroku 在部署时安装包).

Another related question I have is what would occur if a certain package failed to install in the virtual environment: can I manually add it to the requirements.txt or Pipfile? Would this effectively do the same thing as pipenv install ... or is that doing something else beyond adding the package to the list of requirements (considering Heroku is installing the packages upon deployment).

推荐答案

您不需要 requirements.txt.

Pipenv 使用的 PipfilePipfile.lock 旨在替换 requirements.txt.如果您包含所有三个文件,Heroku 将忽略 requirements.txt 并只使用 Pipenv.

The Pipfile and Pipfile.lock that Pipenv uses are designed to replace requirements.txt. If you include all three files, Heroku will ignore the requirements.txt and just use Pipenv.

如果您在本地构建特定库时遇到问题,我敦促您深入研究并让所有内容在您的本地机器上正常运行.但这在技术上不是必需的……只要 PipfilePipfile.lock 包含正确的信息(包括哈希),Heroku 将尝试安装您的依赖项.

If you have build issues with a particular library locally I urge you to dig into that and get everything working on your local machine. But this isn't technically required... as long as the Pipfile and Pipfile.lock contain the right information (including hashes), Heroku will try to install your dependencies.

这篇关于在heroku flask webapp部署中requirements.txt vs Pipfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 18:44