【问题标题】:Why I have a lot of dependecies in requirements.txt file?为什么我在 requirements.txt 文件中有很多依赖项?
【发布时间】:2020-12-04 00:00:06
【问题描述】:

我尝试在 heroku 中部署烧瓶应用程序,但遇到了 requirements.txt 文件的问题。我有100多个模块。我需要 100 个模块来托管吗?我能做什么?

这是我得到的错误:

-----> 检测到 Python 应用程序

-----> 安装python-3.6.11

-----> 安装 pip 20.0.2、setuptools 39.0.1 和 wheel 0.34.2

-----> 安装 SQLite3

-----> 使用 pip 安装需求

   Collecting alabaster==0.7.8

     Downloading alabaster-0.7.8-py2.py3-none-any.whl (27 kB)

   Collecting alembic==1.4.2

     Downloading alembic-1.4.2.tar.gz (1.1 MB)

     Installing build dependencies: started

     Installing build dependencies: finished with status 'done'

     Getting requirements to build wheel: started

     Getting requirements to build wheel: finished with status 'done'

       Preparing wheel metadata: started

       Preparing wheel metadata: finished with status 'done'

   Collecting appdirs==1.4.4

     Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)

   ERROR: Could not find a version that satisfies the requirement apturl==0.5.2 (from -r /tmp/build_1d344ed6_/requirements.txt (line 4)) (from versions: none)

   ERROR: No matching distribution found for apturl==0.5.2 (from -r /tmp/build_1d344ed6_/requirements.txt (line 4))

!推送被拒绝,无法编译 Python 应用。

!推送失败

【问题讨论】:

  • 您在尝试部署烧瓶应用程序时遇到的错误是什么?此外,如果依赖项位于 requirements.txt 中,那么它们很可能是 requirements 。问题可能是它无法找到/检索包,某些依赖项需要更新,或者某些需求相互冲突。
  • 你创建了那个文件,你应该知道你需要什么。没有任何细节,我们怎么可能提供帮助?

标签: python flask heroku


【解决方案1】:

如果您使用 pip freeze > requirements.txt 制作了您的 requirements.txt 那么它将包含您一生安装的所有模块。

如果您正在运行烧瓶应用程序,那么您只需将flask 添加到您的requirements.txt 中。如果您还使用任何其他库,那么您也可以将其包含在您的 requirements.txt 中。

另外,heroku 推荐使用gunicorn,所以你只需要在你的requirements.txt 中包含 flaskgunicorn 或者你需要并且可以使用pip 安装的其他内容。

【讨论】:

    【解决方案2】:

    您可以发布您收到的错误消息吗?

    如果您使用命令pip freeze > requirements.txt 生成了requirements.txt,并且它包含您未使用的依赖项,那么您可能不在只包含此项目的包的虚拟环境中。

    【讨论】:

      猜你喜欢
      • 2018-10-04
      • 1970-01-01
      • 2010-10-15
      • 2022-01-17
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      相关资源
      最近更新 更多