1
votes

I have issues deploying my Django application to AWS in the free tier during the pip installation of my requirements.txt.

As I could see here the issue seems to be related to scipy:

AWS Elastic Beanstalk failed to install Python package using requirements.txt Git Pip

The question has been resolved as he could uppgrade to t2.medium but this requires a paid account. Is there any tip for the free tier?

Could an option like '--no-cache-dir' make it work ? Is there a way to force it (as the pip install is automatically done)

Is there any other way to deploy a Django application on AWS ?

EDIT: It is actually because of psycopg2..

Collecting psycopg2==2.8.4 (from -r /opt/python/ondeck/app/requirements.txt (line 4))

Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)

Complete output from command python setup.py egg_info:

running egg_info

creating pip-egg-info/psycopg2.egg-info

writing pip-egg-info/psycopg2.egg-info/PKG-INFO

writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt

writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt

writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'

warnings.warn(msg)

warning: manifest_maker: standard file '-c' not found

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source. Please add the directory

containing pg_config to the $PATH or specify the full executable path with the

option:

python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

2
Let's take a step back. Nothing here shows us that you're having the same issue as what's in the linked question. What does "I have issues" mean? What is the exact error message that you're seeing, with traceback? See How to Ask.Chris
Sorry let me add my error messageBleuBizarre
Ok I am very sorry, just understood how to check the logs, it fails before that !BleuBizarre
The package psycopg2-binary has a lot of precompiled binary wheels. Try pip install psycopg2-binary (or add it to requirements.txt instead of psycopg2).phd

2 Answers

3
votes

As per @phd comment : pip install psycopg2-binary did the trick instead of pip install psycopg2

0
votes

Although I like the simplicity of the accepted solution, the psycopg2-binary installation notes advise against using it for production:

The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.

I don't know if this really is a big issue, but, for the sake of completeness, I'll add an alternative:

The Error: pg_config executable not found. can also be fixed by installing postgresql-devel using yum.

On Amazon Linux 2 you could do this using .platform hooks. For example, in you app repository (next to your .ebextensions), add a .platform/hooks/prebuild/01_install_yum_packages.sh file with the following content:

#!/bin/bash
yum -y install postgresql-devel

As described in the docs, you have to set execution permissions on this file before committing it to you repo. E.g. chmod +x 01_install_yum_packages.sh.