python-3.x - ld : library not found for -lssl when install psycopg2 in PyCharm terminal

标签 python-3.x pycharm

当我使用此命令在 PyCharm 终端中安装 psycopg2 时:

pip3 install psycopg2

显示错误:

clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g "-DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140001 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/Users/xiaoqiangjiang/source/reddwarf/backend/pydolphin/venv/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -I. -I/opt/homebrew/opt/libpq/include -I/opt/homebrew/opt/libpq/include/postgresql/server -c psycopg/xid_type.c -o build/temp.macosx-10.9-universal2-3.10/psycopg/xid_type.o
    clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_asis.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_binary.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_datetime.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_list.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_pboolean.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_pdecimal.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_pfloat.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_pint.o build/temp.macosx-10.9-universal2-3.10/psycopg/adapter_qstring.o build/temp.macosx-10.9-universal2-3.10/psycopg/aix_support.o build/temp.macosx-10.9-universal2-3.10/psycopg/bytes_format.o build/temp.macosx-10.9-universal2-3.10/psycopg/column_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/connection_int.o build/temp.macosx-10.9-universal2-3.10/psycopg/connection_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/conninfo_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/cursor_int.o build/temp.macosx-10.9-universal2-3.10/psycopg/cursor_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/diagnostics_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/error_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/green.o build/temp.macosx-10.9-universal2-3.10/psycopg/libpq_support.o build/temp.macosx-10.9-universal2-3.10/psycopg/lobject_int.o build/temp.macosx-10.9-universal2-3.10/psycopg/lobject_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/microprotocols.o build/temp.macosx-10.9-universal2-3.10/psycopg/microprotocols_proto.o build/temp.macosx-10.9-universal2-3.10/psycopg/notify_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/pqpath.o build/temp.macosx-10.9-universal2-3.10/psycopg/psycopgmodule.o build/temp.macosx-10.9-universal2-3.10/psycopg/replication_connection_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/replication_cursor_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/replication_message_type.o build/temp.macosx-10.9-universal2-3.10/psycopg/solaris_support.o build/temp.macosx-10.9-universal2-3.10/psycopg/typecast.o build/temp.macosx-10.9-universal2-3.10/psycopg/utils.o build/temp.macosx-10.9-universal2-3.10/psycopg/win32_support.o build/temp.macosx-10.9-universal2-3.10/psycopg/xid_type.o -L/opt/homebrew/opt/libpq/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.9-universal2-3.10/psycopg2/_psycopg.cpython-310-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang' failed with exit code 1

我可以在 macOS Monterey 终端中运行此命令,但在 PyCharm 中不起作用,我应该怎么做才能使其在 PyCharm 终端中运行?我已经尝试重新启动 PyCharm。我错过了什么吗? PyCharm 终端和 macOS 终端有什么不同?

最佳答案

我尝试在 PyCharm 终端中导出 LIBRARY_PATH,如下所示:

export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/Cellar/openssl@3/3.0.1/lib

有效。

关于python-3.x - ld : library not found for -lssl when install psycopg2 in PyCharm terminal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70554279/

相关文章:

python - collections.ChainMap 的目的是什么?

python - 尝试在 OS X El Capitan 上安装 PyCrypto 时出现 fatal error

java - 如何使用蓝牙 getInputStream 和 getOutputStream 的 pyjnius 读写参数?

Python - 在函数内部定义常量

python - 如何从代码中调用 Pycharm 调试器?

python-3.x - Pytest assert_has_calls 用法

python - 制作一个可停止的简单秒表

git - 将 git 存储库克隆到 pycharm

Python项目无法运行

python - 当我有两个版本的 python 时,如何在 PyCharm 中更新 pip?