标签: libpq

Rails 3 - 无法安装pg gem

当我尝试运行bundle(bundle install)时,我总是得到

Installing pg (0.13.2) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include …
Run Code Online (Sandbox Code Playgroud)

macos ruby-on-rails libpq pg postgresql-9.1

96
推荐指数
7
解决办法
8万
查看次数

启动server-libq.5.dylib时Ruby on Rails/PostgreSQL - Library not Loaded错误

我有运行Ruby 1.9.2,Rails 3和postgreSQL 8.3的应用程序.它最初设置并使用postgreSQL 9.1,但我卸载了9.1并安装并更改为8.3以确保Heroku共享数据库设置的兼容性.它运行正常,但现在不行

现在,在处理这个应用程序时,当我运行数据库升级时,我收到此错误:

dlopen(/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib
  Referenced from: /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
  Reason: no suitable image found.  Did find:
    /usr/lib/libpq.5.dylib: no matching architecture in universal wrapper - /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
Run Code Online (Sandbox Code Playgroud)

当我尝试运行服务器时,我收到以下错误消息:

/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg.rb:4:in `require': dlopen(/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError)
  Referenced from: /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
  Reason: no suitable image found.  Did find:
    /usr/lib/libpq.5.dylib: no matching architecture in universal wrapper - /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg.rb:4:in `<top (required)>'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails libpq

18
推荐指数
1
解决办法
6659
查看次数

加载 psycopg2 模块时出错:未加载库:libpq.5.dylib

我正在尝试使用 Postgres 数据库运行 Django 项目。我使用通过 postgressapp 安装的 Postgres 13.4(具有所有当前支持的版本的通用版本)和 python 3.9(在 venv 中)。我在配备 Apple M1 芯片的 Mac、macOS Big Sur 上工作。

\n

我遇到了以下众所周知的问题:

\n
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/mymac/PyCharmProjects/projectname/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/postgresql/lib/libpq.5.dylib\n\xc2\xa0 Referenced from: /Users/mymac/PyCharmProjects/projectname/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so\n\xc2\xa0 Reason: image not found\n
Run Code Online (Sandbox Code Playgroud)\n

通过搜索,我发现了一些这样的讨论:https://github.com/psycopg/psycopg2/issues/1216。看来最相关的解决方案是“RyanDurk\xc2\xa0commented\xc2\xa0on Jan 27”:

\n
$ brew install libpq --build-from-source\n\n$ export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"\n\n$ pip install psycopg2\n
Run Code Online (Sandbox Code Playgroud)\n

不幸的是,就我而言,它没有帮助。

\n

然后,我在这里找到了一些建议:Library not returned: /usr/local/lib/libpq.5.4.dylib并尝试了它们。特别是,我尝试通过符号链接访问 libpq.5.dylib,例如:\nln -s\xc2\xa0 /Library/PostgreSQL/13/lib/libpq.5.dylib /opt/homebrew/opt/postgresql/lib/libpq.5.dylib(该解决方案标记为主题启动器接受),但也没有成功。

\n

我尝试从 postgresql.org 安装 postgres,然后使用 homebrew 卸载/重新安装 …

django postgresql dlopen libpq apple-m1

18
推荐指数
1
解决办法
7137
查看次数

FindPostgreSQL.cmake不适用于ubuntu

  • Ubuntu 12.04
  • CMake 2.8.9
  • Postgresql 9.2.2

我正试图让FindPostgreSQL模块找到/usr/include/postgresql/libpq-fe.h.

这就是我的意思CMakeLists.txt:

find_package(PostgreSQL REQUIRED)
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
  Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found
  version "9.2.2")
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindPostgreSQL.cmake:155 (find_package_handle_standard_args)
  CMakeLists.txt:7 (find_package)
Run Code Online (Sandbox Code Playgroud)

我在调用之前添加了以下行,find_package但它似乎没有任何效果.

set(PostgreSQL_ADDITIONAL_VERSIONS "9.2.2")
set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "/usr/include/postgresql")
Run Code Online (Sandbox Code Playgroud)

我也尝试使用谷歌搜索,PostgreSQL_TYPE_INCLUDE_DIR但没有找到任何东西.我还能尝试什么?

cmake libpq

10
推荐指数
3
解决办法
8091
查看次数

如何解决 Postgresql SCRAM 身份验证问题?

将项目移至生产环境后出现错误。用生产服务器运行时报错如下

pg_connect():无法连接到 PostgreSQL 服务器:SCRAM 身份验证需要 libpq 10 或更高版本。

这是我的 postgreSQL 版本:

开发版本:

x86_64-pc-linux-gnu 上的 PostgreSQL 11.5,由 gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) 编译,64 位

生产版本:

x86_64-pc-linux-gnu 上的 PostgreSQL 11.5 (EnterpriseDB Advanced Server 11.5.12),由 gcc (GCC) 4.8.5 编译 20150623 (Red Hat 4.8.5-36),64 位

database authentication postgresql libpq

10
推荐指数
8
解决办法
2万
查看次数

PostgreSQL的libpq:编码二进制传输ARRAY [] - 数据?

几个小时的文件/委员会/邮件列表并且没有进展我可能会问你:我如何'编码'我的数据用于使用libpq进行二进制传输PQexecParams(.)

简单变量只是大端序:

PGconn *conn;
PGresult *res;
char *paramValues[1];
int paramLengths[1];
int paramFormats[1];

conn = PQconnectdb(CONNINFO);

// -- (1) -- send a float value
float val_f = 0.12345678901234567890; // float precision: ~7 decimal digits
// alloc some memory & write float (in big endian) into
paramValues[0] = (char *) malloc(sizeof(val_f));
*((uint32_t*) paramValues[0]) = htobe32(*((uint32_t*) &val_f)); // host to big endian

paramLengths[0] = sizeof(val_f);
paramFormats[0] = 1; // binary

res = PQexecParams(conn, "SELECT $1::real ;", //
        1, // number parameters …
Run Code Online (Sandbox Code Playgroud)

c c++ postgresql libpq

9
推荐指数
2
解决办法
4684
查看次数

类型转换.如何在C中的libpq中使用PostgreSQL OID值?

我正在使用PostgreSQL C API,libpq.我需要能够将a中的值转换为PGresult*Ruby中的等效数据类型.我目前只是选择所有数据并使用PQgetvalue(),这给了我一个char*我可以转换成ruby String的东西.这很简单.但是否有任何的例子有人可以共享从做一个类型转换char*,比方说,int,float或者double,根据OID由归国PQftype()

实际上,简而言之,我不知道如何解释OID,文档似乎没有给出任何指示.我找到了这个页面,但这无助于理解如何使用此OID在C API中进行类型转换.我猜这里有一个常量列表,我可以从中做出一个很大的转换声明吗?

c postgresql libpq

9
推荐指数
2
解决办法
7983
查看次数

create function unterminated dollar-quoted string

我正在尝试使用postgres(pq lib)数据库使用Goose创建此函数.

我的代码如下:

   CREATE OR REPLACE FUNCTION add_userlocation(user_id INT, location_id INT) RETURNS VOID AS
   $BODY$
   BEGIN
       LOOP
           UPDATE userslocations SET count = count+1 WHERE userid = user_id AND locationid = location_id;
        IF found THEN
            RETURN;
        END IF;
        BEGIN
            INSERT INTO userslocations(userid,locationid, count) VALUES (user_id, location_id, 1);
               RETURN;
           EXCEPTION WHEN unique_violation THEN
        END;
       END LOOP;
   END;
   $BODY$
   LANGUAGE plpgsql;
Run Code Online (Sandbox Code Playgroud)

当我尝试goose up它时提供错误:

(pq: unterminated dollar-quoted string at or near "$BODY$
BEGIN
    LOOP
        -- first try to …
Run Code Online (Sandbox Code Playgroud)

postgresql go libpq goose

9
推荐指数
1
解决办法
1606
查看次数

无法安装 libpq-dev

我正在尝试按照 postgres 的要求安装 libpq-dev,但只收到错误。

pip install libpq-dev==9.4.3

Could not find a version that satisfies the requirement libpq-dev==9.4.3 (from versions: )
No matching distribution found for libpq-dev==9.4.3
Run Code Online (Sandbox Code Playgroud)

python pip libpq

9
推荐指数
1
解决办法
2万
查看次数

无法在 Mac M1 上链接 libpq

我一直在尝试在我的 Macbook M1 上运行 Rust Diesel crate,但它不起作用。编译的最后部分因以下错误而中断:

\n
  = note: ld: warning: ignoring file /usr/local/Cellar/libpq/14.1/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64\n          Undefined symbols for architecture arm64:\n
Run Code Online (Sandbox Code Playgroud)\n

当我得到信息时,libpq我得到以下信息:

\n
maxwellflitton@Maxwells-MacBook-Pro vanguard % brew info libpq                                                           \nlibpq: stable 14.1 (bottled) [keg-only]\nPostgres C API library\nhttps://www.postgresql.org/docs/14/libpq.html\n/usr/local/Cellar/libpq/14.1 (2,335 files, 27.8MB)\n  Poured from bottle on 2022-01-09 at 00:14:32\nFrom: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libpq.rb\nLicense: PostgreSQL\n==> Dependencies\nRequired: krb5 \xe2\x9c\x94, openssl@1.1 \xe2\x9c\x94\n==> Caveats\nlibpq is keg-only, which means it was not symlinked into /usr/local,\nbecause conflicts …
Run Code Online (Sandbox Code Playgroud)

postgresql macos libpq rust-diesel

8
推荐指数
1
解决办法
6611
查看次数