【问题标题】:Deploying django app to Elastic Beanstalk - requirements.txt error将 django 应用程序部署到 Elastic Beanstalk - requirements.txt 错误
【发布时间】:2016-07-01 17:42:17
【问题描述】:

我在部署应用程序时遇到问题,特别是 requirements.txt 文件中的某些模块不满意。不太确定最好的解决方案是什么,因为应用程序的本地版本可以工作。

从日志中可以看出,该错误出现了几次。有没有人遇到过这种情况,如果有,有什么建议或解决方案吗?

日志:

 Collecting mysqlclient==1.3.7 (from -r /opt/python/ondeck/app/requirements.txt (line 17))
    Downloading mysqlclient-1.3.7.tar.gz (79kB)
  Collecting pathspec==0.3.3 (from -r /opt/python/ondeck/app/requirements.txt (line 18))
    Downloading pathspec-0.3.3.tar.gz
  Collecting python-dateutil==2.5.0 (from -r /opt/python/ondeck/app/requirements.txt (line 19))
    Downloading python_dateutil-2.5.0-py2.py3-none-any.whl (199kB)
  Collecting PyYAML==3.11 (from -r /opt/python/ondeck/app/requirements.txt (line 20))
    Downloading PyYAML-3.11.tar.gz (248kB)
  Collecting requests==2.6.2 (from -r /opt/python/ondeck/app/requirements.txt (line 21))
    Downloading requests-2.6.2-py2.py3-none-any.whl (470kB)
  Collecting six==1.10.0 (from -r /opt/python/ondeck/app/requirements.txt (line 22))
    Downloading six-1.10.0-py2.py3-none-any.whl
  Collecting texttable==0.8.4 (from -r /opt/python/ondeck/app/requirements.txt (line 23))
    Downloading texttable-0.8.4.tar.gz
  Collecting vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24))
    Could not find a version that satisfies the requirement vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24)) (from versions: )
  No matching distribution found for vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24))
  You are using pip version 7.1.2, however version 8.1.0 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  2016-03-16 01:55:53,057 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 540, 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 (ElasticBeanstalk::ExternalInvocationError)
caused by: Collecting awsebcli==3.7.3 (from -r /opt/python/ondeck/app/requirements.txt (line 1))
    Downloading awsebcli-3.7.3.tar.gz (172kB)
  Collecting blessed==1.9.5 (from -r /opt/python/ondeck/app/requirements.txt (line 2))
    Downloading blessed-1.9.5-py2.py3-none-any.whl (77kB)
  Collecting botocore==1.4.3 (from -r /opt/python/ondeck/app/requirements.txt (line 3))
    Downloading botocore-1.4.3-py2.py3-none-any.whl (2.2MB)
  Collecting cement==2.4.0 (from -r /opt/python/ondeck/app/requirements.txt (line 4))
    Downloading cement-2.4.0.tar.gz (129kB)
  Collecting colorama==0.3.3 (from -r /opt/python/ondeck/app/requirements.txt (line 5))
    Downloading colorama-0.3.3.tar.gz
  Collecting Django==1.9.1 (from -r /opt/python/ondeck/app/requirements.txt (line 6))
    Downloading Django-1.9.1-py2.py3-none-any.whl (6.6MB)
  Collecting django-cors-headers==1.1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 7))
    Downloading django-cors-headers-1.1.0.tar.gz
  Collecting django-filter==0.11.0 (from -r /opt/python/ondeck/app/requirements.txt (line 8))
    Downloading django_filter-0.11.0-py2.py3-none-any.whl
  Collecting djangorestframework==3.3.1 (from -r /opt/python/ondeck/app/requirements.txt (line 9))
    Downloading djangorestframework-3.3.1-py2.py3-none-any.whl (576kB)
  Collecting docker-py==1.1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 10))
    Downloading docker-py-1.1.0.tar.gz (42kB)
  Collecting dockerpty==0.3.4 (from -r /opt/python/ondeck/app/requirements.txt (line 11))
    Downloading dockerpty-0.3.4.tar.gz
  Collecting docopt==0.6.2 (from -r /opt/python/ondeck/app/requirements.txt (line 12))
    Downloading docopt-0.6.2.tar.gz
  Collecting docutils==0.12 (from -r /opt/python/ondeck/app/requirements.txt (line 13))
    Downloading docutils-0.12.tar.gz (1.6MB)
  Collecting jmespath==0.9.0 (from -r /opt/python/ondeck/app/requirements.txt (line 14))
    Downloading jmespath-0.9.0-py2.py3-none-any.whl
  Collecting jsonfield==1.0.3 (from -r /opt/python/ondeck/app/requirements.txt (line 15))
    Downloading jsonfield-1.0.3.tar.gz
  Collecting MySQL-python==1.2.5 (from -r /opt/python/ondeck/app/requirements.txt (line 16))
    Downloading MySQL-python-1.2.5.zip (108kB)
  Collecting mysqlclient==1.3.7 (from -r /opt/python/ondeck/app/requirements.txt (line 17))
    Downloading mysqlclient-1.3.7.tar.gz (79kB)
  Collecting pathspec==0.3.3 (from -r /opt/python/ondeck/app/requirements.txt (line 18))
    Downloading pathspec-0.3.3.tar.gz
  Collecting python-dateutil==2.5.0 (from -r /opt/python/ondeck/app/requirements.txt (line 19))
    Downloading python_dateutil-2.5.0-py2.py3-none-any.whl (199kB)
  Collecting PyYAML==3.11 (from -r /opt/python/ondeck/app/requirements.txt (line 20))
    Downloading PyYAML-3.11.tar.gz (248kB)
  Collecting requests==2.6.2 (from -r /opt/python/ondeck/app/requirements.txt (line 21))
    Downloading requests-2.6.2-py2.py3-none-any.whl (470kB)
  Collecting six==1.10.0 (from -r /opt/python/ondeck/app/requirements.txt (line 22))
    Downloading six-1.10.0-py2.py3-none-any.whl
  Collecting texttable==0.8.4 (from -r /opt/python/ondeck/app/requirements.txt (line 23))
    Downloading texttable-0.8.4.tar.gz
  Collecting vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24))
    Could not find a version that satisfies the requirement vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24)) (from versions: )
  No matching distribution found for vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24))
  You are using pip version 7.1.2, however version 8.1.0 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  2016-03-16 01:55:53,057 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 540, 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)

【问题讨论】:

    标签: python django amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    在本地环境中运行 pip freeze。这应该会给你一个依赖列表。

    例如,我在 AWS 上的一个应用程序中使用了这个

    requirements.txt

    boto==2.38.0
    Django==1.6.4
    MySQL-python==1.2.5
    argparse==1.3.0
    dj-database-url==0.3.0
    wsgiref==0.1.2
    south==0.8.4
    whoosh==2.7.0
    django-haystack==2.4.0
    django-elasticache==0.0.3
    pylibmc==1.5.0
    django-storages==1.1.8
    

    还有你的 .config 文件`可能需要一些 yum 包,例如:

    myapp.config

    packages:
        yum:
            python27-devel: []
            libmemcached-devel: []
            libjpeg-turbo-devel: []
    #01_syncdb:
    ...
    

    你的答案可能在这里:Error while full update pip packages

    【讨论】:

    • 是的,我跑了pip freeze > requirements.txt,输出:Django==1.9.2 django-cors-headers==1.1.0 django-filter==0.13.0 djangorestframework==3.3.3 Markdown==2.6.5 MySQL-python==1.2.5
    • 运行它并输出正确的依赖项,不知道为什么我在尝试部署时仍然遇到同样的错误......
    • vboxapi 甚至没有显示当我将 pip freeze 作为依赖项运行时。不知道为什么它在我尝试部署时显示
    • Collecting vboxapi==1.0 (from -r /opt/python/ondeck/app/requirements.txt (line 24))
    • vboxapi 尝试了 pip 忽略相同的结果...奇怪
    【解决方案2】:

    好吧,我终于让它工作了,尽管它没有为我的原始问题提供答案。我基本上不得不从父 django 文件夹中压缩文件。一旦我这样做并重新上传它,包括requirements.txt,应用程序就成功部署了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-22
      • 2013-09-04
      • 2015-09-21
      • 2020-09-02
      • 2022-12-09
      • 2013-12-15
      • 2021-02-11
      • 2018-12-07
      相关资源
      最近更新 更多