dbcli/pgcli

UserWarning: The psycopg2 wheel package will be renamed from release 2.8

ncFoCo opened this issue Β· 22 comments

Description

The psycopg2 package display's a user warning when calling pgcli. They have a blog post describing why this warning is displayed: http://initd.org/psycopg/articles/2018/02/08/psycopg-274-released/.

Warning Message

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>.

Your environment

  • pgcli is installed in a virtual environment in my home .local folder.
  • Symlink pgcli in my .local/bin folder to the virtual instance of pgcli.

System Information

  • Please provide your OS and version information.
    Ubuntu 16.04.3 LTS (xenial, x86_64)

  • Please provide your CLI version.
    pgcli Version: 1.8.2

  • What is the output of pip freeze command.

cli-helpers==1.0.1
click==6.7
configobj==5.0.6
humanize==0.5.1
pgcli==1.8.2
pgspecial==1.9.0
prompt-toolkit==1.0.15
psycopg2==2.7.4
Pygments==2.2.0
setproctitle==1.1.10
six==1.11.0
sqlparse==0.2.4
tabulate==0.8.2
terminaltables==3.1.0
wcwidth==0.1.7

Downgrading to psycopg2 v2.7.3.2 avoids the warning (pip install psycopg2==2.7.3.2). But, it would be preferable to stick with the most recent psycopg2 package.

Do you guys know if this warning can be suppressed?

Thanks!

@pshlykov If you are running pglci from a virtual environment you can install psycopg2 v2.7.3.2 to get around the warning. By default, pgcli will install the latest version of psycopg2.

I'll change the dependency to psycopg2-binary.

Thanks for reporting.

Released in 1.9.0.

@amjith Changing the dependency to psycopg2-binary excludes people that have problems with the psycopg2 binary wheel package from using pgcli >= 1.9.0.

Since binary wheels were introduced in psycopg2 just one year ago, I think it's more reasonable to continue to depend on psycopg2, which will be a source-only package starting from 2.8. This will emit a warning until psycopg2 2.8 is released, which is discussed in this ticket and on the psycopg2 homepage linked above.

GIS90 commented

pip install psycopg2 (2.7.4)
pip install psycopg2-binary (2.7.4)
I install the 2.7.4 version,but the promble is not solve
pip list:
pbr (4.0.0)
pika (0.11.2)
pip (8.1.1)
psycopg2 (2.7.4)
psycopg2-binary (2.7.4)
pyasn1 (0.4.2)
pyasn1-modules (0.2.1)
python-ldap (3.0.0)
python-mimeparse (1.6.0)

help

@GIS90 Uninstall the old psycopg2 package; your system should switch to using the -binary package automatically.

pip install psycopg2-binary

this problem might be coz of you did not migrate your database
-$ ./manage.py migrate (for djnago)

I know that adding to this post probably won't help, but I actually want to stick with psycopg2 (not use the binary) but get rid of that really annoying warning.

I actually ran into an unusual edge-case where the psycopg2-binary wheel didn't work properly for me in one particular project only (got some strange byte alignment error, I guess this is why the wheel version didn't work that well).

Does this really mean I have to put up with the warning until version 2.8 is released.

edit: I was actually forced to install 2.6.2 (the last version before the switch to wheels) in this project because the wheel version had the alignment error come up, so really the 2.8 release is quite important for me and hope it's soon as it fixes this mess.

The warning is silenced in pgcli (starting 1.10.0): #894.

@GIS90 Uninstall the old psycopg2 package; your system should switch to using the -binary package automatically.

May I ask why this was downvoted? In the interest of education.

The error message notification starting with version 2.8 of psycopg2 requires the following installation.

pip install psycopg2-binary

If you're using version 2.x being, can ignore this warning tip.

How do you silence this warning if you want to use psycopg2 source?

Not sure. I attempted to silence them before:

warnings.filterwarnings("ignore", category=UserWarning, module='psycopg2')

that trick worked for a little bit and then stopped. You're welcome to try and poke around some more with warnings. If you find the right way to do that, we'll welcome a PR!

It still works @j-bennet it just has to be one of the first things that loads when your app starts up. I had to move some code to ensure the warnings.filterwarning(...) loaded first when starting the app and use this in several applications.

Edit: I don't know why pgcli imports from pgspecial.namedqueries before the filterwarnings statement, this also doesn't really follow python imports grouping convention where only standard lib imports should be first

Would it be possible to allow either to be used? My project depends on the binary version and having to have both installed for pgcli is a bit of a nuisance. Would be appreciated.

Because of I did rebuild from source of psycopg 2.8.3, then my project raised the message too.
I removed pycache, it was fine for me.
rm -rf pycache/

Because of I did rebuild from source of psycopg 2.8.3, then my project raised the message too.
I removed pycache, it was fine for me.
rm -rf pycache/

This solution worked for me.

uninstall psycopg2 :
pip uninstall psycopg2

install psycopg2-binary:
install pip install psycopg2-binary

system switch using the psycopg2-binary package automatically