1 diff --git a/psycopg/psycopg/pq/_pq_ctypes.py b/psycopg/psycopg/pq/_pq_ctypes.py
2 index 4f9d00fb..24b90ef6 100644
3 --- a/psycopg/psycopg/pq/_pq_ctypes.py
4 +++ b/psycopg/psycopg/pq/_pq_ctypes.py
5 @@ -11,14 +11,10 @@ from ctypes import Structure, CFUNCTYPE, POINTER
6 from ctypes import c_char, c_char_p, c_int, c_size_t, c_ubyte, c_uint, c_void_p
7 from typing import List, Optional, Tuple
9 -from .misc import find_libpq_full_path
10 from ..errors import NotSupportedError
12 -libname = find_libpq_full_path()
14 - raise ImportError("libpq library not found")
16 -pq = ctypes.cdll.LoadLibrary(libname)
17 +pq = ctypes.cdll.LoadLibrary("@libpq@")
20 class FILE(Structure):
21 @@ -28,9 +24,7 @@ class FILE(Structure):
22 FILE_ptr = POINTER(FILE)
24 if sys.platform == "linux":
25 - libcname = ctypes.util.find_library("c")
27 - libc = ctypes.cdll.LoadLibrary(libcname)
28 + libc = ctypes.cdll.LoadLibrary("@libc@")
31 fdopen.argtypes = (c_int, c_char_p)
32 diff --git a/tests/fix_pq.py b/tests/fix_pq.py
33 index 6811a26c..c1829c82 100644
36 @@ -51,9 +51,7 @@ def libpq():
37 from psycopg.pq.misc import find_libpq_full_path
39 # Not available when testing the binary package
40 - libname = find_libpq_full_path()
41 - assert libname, "libpq libname not found"
42 - return ctypes.pydll.LoadLibrary(libname)
43 + return ctypes.pydll.LoadLibrary("@libpq@")
44 except Exception as e:
45 if pq.__impl__ == "binary":
46 pytest.skip(f"can't load libpq for testing: {e}")