Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Program Won't Run - psycopg2 rename warning

I am on a mac, using vagrant in the terminal. I am trying to run a program in python that uses psycopg2. I kept getting an error that psychopg2 module didn't exist when I would run 'python3 sample.py'. So I ran 'pip3 install psycopg2'. Now I get the error below and despite reading documentation in multiple places, I cannot solve this issue. So now my programs won't run.

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psycopg2/__init__.py:144: 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>.
  """)
like image 477
rabowlen Avatar asked Jul 02 '18 17:07

rabowlen


2 Answers

That is a warning and not an error. It will not prevent your program from running.

like image 22
Richard Simões Avatar answered Nov 04 '22 22:11

Richard Simões


That's just a warning, your program should still run fine.

The warning is the result of a decision by the package maintainer to discontinue the use of wheel packages in psycopg2. The psycopg2 package is now designed to be built from source, while psycopg2-binary maintains the current installation method but has a few bugs which trigger segfaults. Both packages provide the same interface, so you shouldn't need to make any code updates for either option.

The easiest solution is to just install the binary package and the warning will go away:

pip install psycopg2-binary

If you prefer to install the version without the segfault bugs, have pip install from source using the --no-binary flag:

pip install --no-binary :all: psycopg2

If you're using a requirements.txt file, add a line like this:

psycopg2>=2.7,<2.8 --no-binary psycopg2

Update

With the release of psycopg 2.8, the warning and binary packages have now been removed. All you need to do now is install/update psycopg2 normally and the warning will go away:

pip install psycopg2

With a requirements.txt:

psycopg2>=2.8

If you do want to keep using the binary packages for any reason, psycopg2-binary remains available.

like image 96
Brad Koch Avatar answered Nov 04 '22 22:11

Brad Koch