Epulari
Epulari

Reputation: 59

pypy3 import psycopg2 error (undefined symbol: PyCoder_Encoder)

I installed psycopg2 to pypy3(Python3.5.3) by the following code on Ubuntu16.04:

pypy3 -m pip install psycopg2

However, I got some errors:

Error:b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-epd368s6/psycopg2

And I found the solution in "You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application".

My computer has already installed Postgresql9.5, so I used these commands to install:

sudo apt-get install libpq-dev
pypy3 -m pip install psycopg2

No error was reported, but when I tried "import psycopg2", I got ImportError:

enter image description here

I found the same error in "pypy3 import psycopg2 error (PyCodec_Encoder)", but I did not found a solution.

Do someone know how to fix it?

Upvotes: 4

Views: 2783

Answers (2)

DejanLekic
DejanLekic

Reputation: 19797

psycopg2-binary works with latest version of PyPy 3.6 (nightly build from 2020-01-23) as it contains the PyCodec_Encoder and PyCodec_Decoder implementations.

Upvotes: 2

mattip
mattip

Reputation: 2563

The PyPy issue you pointed to contains the answer "Someone will have to implement the missing function (and the other missing PyCodec_* functions. Currently we only implement very few in codec.py. The implementation is quite straight-forward based on the pattern in the functions implemented, the harder part is writing tests.

There is the psycopg2cffi package, which should work on PyPy and will be faster. Perhaps give it a try and comment here if it serves your needs.

Upvotes: 5

Related Questions