首页 > 解决方案 > psycopg2 所需的 Ubuntu 20.04 缺少的 postgres-plpython-12 在哪里?

问题描述

postgres-plpython-12 没有可用的软件包

https://packages.ubuntu.com/search?keywords=postgresql-plpython

psycopg2 库不能与 plpython3 一起使用(或者可以)?

psycopg2.errors.UndefinedFile: could not access file "$libdir/plpython2": No such file or directory

那么如何让 psycopg2 在 Ubuntu >= 20.04 上工作呢?

libpq*已安装。

libpq-dev is already the newest version (13.4-1.pgdg18.04+1).
libpq5 is already the newest version (13.4-1.pgdg18.04+1).

也许一切都必须在 postgres-13 上?libpq*由于版本 12.x似乎没有明确的候选者

上面的错误是由 pytest-postgresql 从


postgresql = <connection object at 0x7fa79feaf548; dsn: 'user=postgres password=xxx dbname=app_test host=127.0.0.1 port=15988 options=''', closed: 0>

    @pytest.fixture
    def postgresql_config(postgresql) -> Dict:
        # https://github.com/ClearcodeHQ/pytest-postgresql#how-to-use
        # https://github.com/ClearcodeHQ/pytest-postgresql#configuration
        # see pytest.ini for configuration options
    
        # assert isinstance(postgresql, connection)
        dsn = postgresql.get_dsn_parameters()
        passwd_data = Path(dsn["passfile"]).read_text().strip()
        passwd = passwd_data.split(":")[-1]
        dsn_path = f"{dsn['user']}:{passwd}@{dsn['host']}:{dsn['port']}"
        db_url = f"postgresql+psycopg2://{dsn_path}/{dsn['dbname']}"
        admin_config = {
            "timeout": 10,
            "host": dsn["host"],
            "port": dsn["port"],
            "dbname": dsn["dbname"],
            "username": dsn["user"],
            "password": passwd,
            "url": db_url,
        }
    
        # - init the test-db using the postgres admin user
        # - for some tips on idempotent DDL, see:
        #   https://www.depesz.com/2008/06/18/conditional-ddl/
    
        cursor = postgresql.cursor()
        for statement in sqlparse.split(_setup_sql):
            if statement:
>               cursor.execute(statement)
E               psycopg2.errors.UndefinedFile: could not access file "$libdir/plpython2": No such file or directory

标签: postgresqlpostgispsycopg2plpython

解决方案


推荐阅读