Rodrigo Avila

Home

Como corrigir erro com psycopg2 no pg_activity

Published Oct 08, 2021

Caso você encontre um erro no psycopg2 ao executar o pg_activity:

[[email protected] ~]# pg_activity -U postgres
Traceback (most recent call last):
  File "/bin/pg_activity", line 11, in <module>
    load_entry_point('pg-activity==2.2.1', 'console_scripts', 'pg_activity')()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.6/site-packages/pgactivity/cli.py", line 8, in <module>
    from psycopg2.errors import OperationalError
  File "/usr/lib64/python3.6/site-packages/psycopg2/__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
ImportError: /usr/lib64/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PQencryptPasswordConn

Os comandos abaixo podem ajudar a resolver o problema.

# pip3 uninstall psycopg2
# pip install --upgrade pip
# pip3 install psycopg2-binary