Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psycopg-binary is not recommended for production #3

Open
jaromey opened this issue Oct 3, 2019 · 8 comments
Open

psycopg-binary is not recommended for production #3

jaromey opened this issue Oct 3, 2019 · 8 comments

Comments

@jaromey
Copy link

jaromey commented Oct 3, 2019

This repo is referenced in the Microsoft Azure doc, "Build a Python (Django) web app with PostgreSQL in Azure App Service". However, the requirements.txt file in this repo uses pyscopg2-binary which is not the recommended library for production. There is nothing in the doc that suggests that the pyscopg2-binary libary should be avoided for production which can give developers the impression that this is the standard library that should be used.

The problem is that pyscopg2 does not install on Azure App Service for Linux because the container doesn't have the dependency to build pyscopg2. So there is no choice but to use pyscopg2-binary. If there is a walk-through on the Azure docs to deploy a Django app with Postgres then the container that is used for Azure app service should be able to build psycopg2 which is the recommendation for production. I think it is very misleading otherwise.

@egachi
Copy link

egachi commented Oct 28, 2019

Hi @jaromey, I have tested this example with the following libraries in the requirements.txt:

Django==2.1.2
psycopg2==2.8.4
pytz==2018.5
whitenoise==4.1

And I was able to deploy it to Azure Web App Linux with Python 3.7, as this image depends in Oryx image, the dependency (libpq-dev) for installing psycopg2 is listed there:

https://github.com/microsoft/Oryx/blob/master/images/runtime/python/install-dependencies.sh#L16

@jaromey
Copy link
Author

jaromey commented Oct 28, 2019

Thanks for your response @edisga. I was never able to got psycopg2 to install in Azure Web App for Linux with Python 3.7. The workaround that I did was to use wheels to pre-compile psycopg. So in our build process we had the following:

pip install wheel
pip wheel -r vendor-requirements.txt -w wheelhouse

Contents of vendor-requirements.txt:
psycopg2==2.8.3

Then in our regular requirements.txt file we had the following:

--find-links wheelhouse
Django==2.2.5
psycopg2==2.8.3
pytz==2019.2
whitenoise==4.1.4
...

However, you said that it worked for you so I am wondering if I am missing something. Is there some configuration that I needed to do?

@jaromey jaromey changed the title pyscopg-binary is not recommended for production psycopg-binary is not recommended for production Oct 28, 2019
@MutatedGamer
Copy link

MutatedGamer commented Jul 23, 2020

I'm also experiencing the same issue. I just fired up a fresh B1 instance and can cannot get psycopg2 installed, only psycopg2-binary. When trying to install psycopg2, it says

unable to execute 'gcc': No such file or directory

@kraigb
Copy link
Contributor

kraigb commented Sep 23, 2020

Removed the reference so that only Django is in requirements.txt. Thanks.

@kraigb kraigb closed this as completed Sep 23, 2020
@kraigb
Copy link
Contributor

kraigb commented Sep 29, 2020

Reopening because of changes to requirements.txt, which leaves this issue unresolved.

@kraigb kraigb reopened this Sep 29, 2020
@ddhanesha
Copy link

We are having the same issue while installing pyscopg2 library. Would love get a solution for this. Dont want to run pyscopg2-binary for my production environment.

@kraigb
Copy link
Contributor

kraigb commented Oct 3, 2020

We're working to get gcc installed in the host container, which would allow psycopg2 to install automatically as a django dependency. Thanks for your feedback, as it should help prioritize that update.

@Sumit4983
Copy link

I found a compiled version of psycopg2
And copied the same to my current directory of the project and it worked.

Hope it helps someone who is still looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants