【问题标题】:Elastic Beanstalk installing scipyElastic Beanstalk 安装 scipy
【发布时间】:2017-08-27 03:48:29
【问题描述】:

我正在尝试在 Amazon Elastic Beanstalk 上运行的基本 Django 应用程序上安装 scipy,但无法正常工作。

以下是重现我的问题的步骤:

来自the guide的常规内容:

# Create a new virtual environment
mkvirtualenv -p python2.7 django_eb

# Install Django on it
pip install django==1.9.12
# pip freeze should now show Django==1.9.12 and some other things

# Start a new Django project 
# This creates a directory that has everything you need for Django
django-admin startproject django_eb
cd django_eb

# Optionally check that the site works
python manage.py runserver
Ctrl-C

# Store the pip requirements so that the remote host can install them
pip freeze > requirements.txt

# Tell the remote server where our wsgi file is
mkdir .ebextensions
cat <<EOT >> .ebextensions/django.config
option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: django_eb/wsgi.py
EOT

# Allow any host for our project
# If this is unset, you'll get a 404 on the deployed site
set ALLOWED_HOSTS = ['*'] in settings.py

# Create an EB project
# Will need AWS EB CLI for this
eb init -p python2.7 django_eb
# Choose some region
eb init
# choose Y so we can SSH and check logs

# Create a deployment environment
eb create django-eb-env 
# This step takes around 5 minutes
# If it fails and you need to restart run 'eb deploy'

# Open the website in your OS's default browser
eb open
# If you get DisallowedHost at / error
# double check that ALLOWED_HOSTS = ['*']

安装 scipy:

# Now we'll install scipy and watch how it doesn't work remotely
pip install scipy==0.19.0
pip freeze > requirements.txt
eb deploy
# Should take forever and then finally print 
# 'ERROR: Failed to deploy application.'

eb ssh
cat /var/log/eb-activity.log
# Should print
# numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

# After reading this blog post
# https://medium.com/@DaveJMcKeown/deploying-scipy-into-aws-elastic-beanstalk-2e5e481155de
# I added this to .ebextensions/django.config:
packages:  
  yum:
    make: []
    gcc-c++: []
    gcc-gfortran: []
    python27-devel: [] # I used python27-devel instead of python-devel
    atlas-sse3-devel: []
    lapack-devel: []
    libpng-devel: []
    freetype-devel: []
    zlib-devel: []
container_commands:  
  AddGlobalWSGIGroupAccess: 
    command: "if ! grep -q 'WSGIApplicationGroup %{GLOBAL}' ../wsgi.conf ; then echo 'WSGIApplicationGroup %{GLOBAL}' >> ../wsgi.conf; fi;"

# Unfortunately, this leads to an our of memory error
# Running dmesg now looks like the following:
# http://stackoverflow.com/a/35011967/2770572

我在这里不知所措。似乎我可以让它在具有更多 RAM 的 EC2 实例上工作,但我不能真正做到这一点,因为它会使我脱离免费套餐。有没有办法运行 make 命令使其不占用太多内存或其他解决方案?

【问题讨论】:

  • 这里也一样。我找到了这种方式告诉 EB 上传我的 pip 版本:commands: 00_update_pip: command: "/opt/python/run/venv/bin/pip install --upgrade pip"。我很想知道是否有任何方法可以告诉 EB 类似pip install --no-cache-dir -r requirements.txt 的信息。我记得我在EB实例上安装包directiy时遇到过几次,我就是这样解决的。
  • 我的回答对你有用吗?
  • @MattiaPaterna 在你回答的时候我已经停止工作了,所以 idk

标签: linux django scipy amazon-elastic-beanstalk yum


【解决方案1】:

您可以尝试将此添加到您的.ebextensions/django.config

commands:
  01_no_cache:
    command: "/opt/python/run/venv/bin/pip install --no-cache-dir -r /opt/python/current/app/requirements.txt"

如果您检查 /var/log/eb-activity.log(或者如果您安装了 EB CLI,则只需输入 eb logs),您可以在此处看到错误:

MemoryError
2017-08-10 11:40:25,557 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 2

据我所知,如果您将特定命令包含在 django.config 中,您可以为您的 EB 提供特定命令。如here 所写,您可以禁用缓存。

这对我有用。

【讨论】:

    猜你喜欢
    • 2018-07-01
    • 2018-05-25
    • 2018-05-12
    • 1970-01-01
    • 2014-09-15
    • 2013-03-05
    • 2017-03-26
    • 2020-06-08
    • 2013-07-08
    相关资源
    最近更新 更多