Setting the message language and encoding used by the application requires the same environment setup as using the C language library.
However, the Python language package (psycopg) cannot use the PQsetClientEncoding function to set the encoding. Use the SET command with the execute function to specify the encoding for client_encoding.
For information about settings in the C language library, refer to "5.2.2 Message Language and Encoding System Used by Applications Settings" in the "C Library (libpq)".