我跑
sudo pip install psycopg2
我得到了一组输出,看起来像:
cc -DNDEBUG -g -fwrapv -Os .....
.....
cc -DNDEBUG -g -fwrapv -Os .....
.....
最后它说:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/bz/pvj1g9xj16d10pjjgbrfl3fw0000gn/T/pip_build_root/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/bz/pvj1g9xj16d10pjjgbrfl3fw0000gn/T/pip-uE3thn-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/bz/pvj1g9xj16d10pjjgbrfl3fw0000gn/T/pip_build_root/psycopg2
Storing debug log for failure in /Users/Tyler/Library/Logs/pip.log
运行easy_install或从源代码执行都会在最后给出相同的错误(关于-lssl的库未找到的部分)
运行brew安装(或升级)openssl会产生以下结果
$ brew upgrade openssl
Error: openssl-1.0.1h already installed
有人能帮我吗
对于在macOS Sierra 10.12(或更高版本,最有可能)上寻找此解决方案的任何人:我通过安装命令行工具修复了此问题:
在那之后,
pip install psycopg2
应该会起作用如果没有,您还可以尝试链接brew的openssl:
通过brew安装openssl。请注意
brew link openssl --force
不再工作:正如@macho在下面指出的,如果这仍然不起作用,您可能需要使用pip的
--no-cache
选项,例如记住,如果您构建在ARM/Apple M1 Mac上,请相应地调整这些路径(因为homebrew安装在
/opt/homebrew/
);命令如下:我从brew安装了OpenSSL(
brew install openssl
)以下几点对我很有用:
使用
brew link openssl
是危险的,因为它可能会通过将Homebrew的OpenSSL头进行符号链接而弄乱您的系统,而实际的库仍然是系统提供的库,从而导致各种问题。如果您尝试,Homebrew实际上会警告您不要这样做(其他答案表明链接无论如何也解决不了问题):以下是您需要使用的
pip
命令:对于
pipenv
,我不知道您可以传递给它的任何命令行属性,但是您可以在运行pipenv install
之前将上述路径导出为环境变量:相关问题 更多 >
编程相关推荐