首页 > 解决方案 > 损坏的Requirements.txt?

问题描述

要提供有关我的问题的所有详细信息,最好提供一些背景故事。在过去的几个月里,我一直在工作中从事一个 Django 项目。由于最近发生的明显事件,我在家工作,因此我不得不将项目转移到我的家用 PC(使用 Git)。

在工作中,我制作了一个 requirements.txt,我会用它来获取家里的所有包。这行得通,但它不会在家里安装,我很快发现这是因为 requirements.txt 有一个无效且不存在的包。这是: pkg-resources==0.0.0

我从需求文件中删除了它,之后一切正常。

快进到现在:我正在尝试在我们的 amazon beanstalk 上部署该项目,但由于此错误而失败:

2020-03-26 12:03:10    ERROR   Your requirements.txt is invalid. Snapshot your logs for details.
2020-03-26 12:03:13    ERROR   [Instance: i-0xxxxxxx] Command failed on instance. Return code: 1 Output: (TRUNCATED)...)
  File "/usr/lib64/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2020-03-26 12:03:13    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-03-26 12:03:13    ERROR   Unsuccessful command execution on instance id(s) 'i-09xxxxxxxx'. Aborting the operation.
2020-03-26 12:03:13    ERROR   Failed to deploy application.

ERROR: ServiceError - Failed to deploy application.

所以我按照建议做了,查看活动日志并查看:

  Collecting pkg-resources==0.0.0 (from -r /opt/python/ondeck/app/requirements.txt (line 34))
    Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r /opt/python/ondeck/app/requirements.txt (line 34)) (from versions: )
  No matching distribution found for pkg-resources==0.0.0 (from -r /opt/python/ondeck/app/requirements.txt (line 34))
  You are using pip version 9.0.1, however version 20.0.2 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  2020-03-26 11:40:21,832 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
      install_dependencies()
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
      check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
    File "/usr/lib64/python2.7/subprocess.py", line 190, in check_call
      raise CalledProcessError(retcode, cmd)
  CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

其中包含:

No matching distribution found for pkg-resources==0.0.0

我不明白为什么它要查找我前段时间从需求文件中删除的无效包。我尝试过制作一个全新的需求文件并进行部署,我尝试过在没有需求文件的情况下进行部署,我尝试过对其进行更改,将其推送到 Git 然后进行部署,但都没有成功。

它还说第 34 行,而我的需求文件实际上是 33 行。

标签: pythondjangopipamazon-elastic-beanstalk

解决方案


推荐阅读