Fixing psycopg2 Warning for Flask-SQLAlchemy
While working on my first app, an Amazon Review Scraper, I encountered a really annoying warning using SQLAlchemy with my Postgres database.
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
It’s just a warning, but every time I save something to the database there it is annoying me with its words about future incompatibility. It basically even tells me how to fix it. Here’s where the real problems start. First, if you follow the instructions and install psycopg2-binary, well, the warning persists. Now you have both! But Flask-SQLAlchemy is just ignoring the binary version and still throwing warnings at me left and right. What the warning should have told me is this. Uninstall psycopg2, then install pyscopg2-binary. So, my thoughts were to uninstall psycopg2, that makes sense right? Nope, now i get errors because there is no psycopg2 installed…..what? What about psycopg2-binary, why is it still not working? Checking my installed dependencies shows it’s there…what is happening?
How I understand what’s going on
With both packages installed, when you uninstall pyscopg2, it uninstalls both packages but psycopg2-binary still shows as being installed but that’s in name only, none of it’s contents are there anymore.
The Fix — TL;DR
Ok, here is what you need to do.
Uninstall BOTH pyscopg2 and psycopg2-binary.
Then, install ONLY psycopg2-binary.
Look what happened, no warnings, no errors.
Conclusions
I am sure it is because I am new to all of this but I could not find this information anywhere about this topic. I think people assume you would know you should uninstall psycopg2 before then install psycopg2-binary but as this was a dependency of Flask-SQLAlchemy in the first place I really didn’t know that was what I was meant to do. Hopefully this is helpful to anyone that finds themselves in this same situation as me.