2017-04-02 35 views
1

我想在裸機在Amazon Elastic青苗運行Django應用程序安裝SciPy的,但我不能得到它的工作。彈性魔豆安裝已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 

我不知所措就在這裏。看起來我也許可以在EC2實例中使用更多的RAM,但我無法真正做到這一點,因爲它會讓我脫離免費層。有沒有辦法運行make命令,以便它不佔用太多的內存或其他解決方案?

+0

同樣在這裏。我發現這個方法來告訴EB上傳我的PIP版本:'命令: 00_update_pip: 命令: 「/選擇/蟒蛇/運行/ VENV /斌/ PIP安裝--upgrade點子」'。 我很想知道是否有任何方法告訴EB像'pip install --no-cache-dir -r requirements.txt'這樣的東西。我記得當我在EB實例上安裝packages * directiy *時,曾多次使用過這種方法,並且我通過這種方式解決了這個問題。 –

+0

我的答案是否適合你? –

+0

@MattiaPaterna當你回答這個問題時,我停止了對它的工作 – michaelsnowden

回答

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 logs如果您已經安裝了EB CLI),你可以在這裏看到的錯誤:

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,您可以禁用緩存。

這對我有效。