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

ImportError: undefined symbol: PQencryptPasswordConn #1462

Closed
mathihg opened this issue Jun 14, 2022 · 3 comments
Closed

ImportError: undefined symbol: PQencryptPasswordConn #1462

mathihg opened this issue Jun 14, 2022 · 3 comments

Comments

@mathihg
Copy link

mathihg commented Jun 14, 2022

Hi,

I am all new to postgres and psycopg2 so I am sorry for my bad language and explaining.

I have an easy Python application running on a Revolution Pi but I get error when importing the psycopg2:

ImportError: undefined symbol: PQencryptPasswordConn

Here is my information

I have tried reinstalling the packages using both pip and build from source, as many suggest from 1018 and 1093, but the error is still present.

What am I missing?

Thanks

@dvarrazzo
Copy link
Member

Hello,

I suspect you have more than one libpq installed in the system: at build time a newer version is used (Postgres >= 10, which includes the above function), but at runtime an older version is found.

What have you got related to libpq in your system? You can check with:

find / -name \*libpq\*

What pg_config is found?

which pg_config
pg_config --version
pg_config --libdir

What libpq is being used at runtime? The libpq is dynamically linked to the C module, which is named in a pattern such as _psycopg.cpython-38-x86_64-linux-gnu.so, and should be found in a directory site-package/psycopg2 in your Python path.

# Find possible candidates
find . -name _psycopg\*.so

# for instance, on my system I get:
ldd ./build/lib.3.8/psycopg2/_psycopg.cpython-38-x86_64-linux-gnu.so
	linux-vdso.so.1 (0x00007ffc772e9000)
	libpq.so.5 => /lib/x86_64-linux-gnu/libpq.so.5 (0x00007fd94a8c5000)
	...

the last path is somewhere in your Python packages, it refers to a file

@mathihg
Copy link
Author

mathihg commented Jun 14, 2022

Thank you for a quick respond!

The first command resulted in:
image
So the package is installed for python 3.9?

pg_config is located at /usr/bin/pg_config with version 9.6.24 and --libdir == /usr/lib/arm-linux-snueabihf

the command find - -name _psycopg\*.so results in
./.local/lib/python3.5/site-packages/psycopg2/_psycopg.cpython-35m-arm-linux-gnueabihf.so
in the python 3.5 path.

The application works fine when running on python 3.5, but how can I make it work with 3.9?

@dvarrazzo
Copy link
Member

psycopg2cffi is a separate package: see here: https://pypi.org/project/psycopg2cffi/ If that's what you are trying to use you should hear from that project, not from this one.

The application works fine when running on python 3.5, but how can I make it work with 3.9?

I don't know which architecture the raspberry pi is, so I assume psycopg2-binary will not work. Try to remove every bit you find about psycopg, then pip install psycopg2 making sure that pip is related to Python 3.9.

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

2 participants