2014-10-09 54 views
48

我运行“命令PIP安装psycopg2”我得到了一堆的输出,看起来像错误安装psycopg2,图书馆没有找到-lssl

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或源做都给予我同样的错误在最后(没有发现-ls有关图书馆的一部分SL)。


运行BREW安装(或升级)的OpenSSL产生以下

$ brew upgrade openssl 
Error: openssl-1.0.1h already installed 

谁能帮助我吗?

回答

-2

我已经设法通过使用来解决它:

brew unlink openssl && brew link openssl --force 

我不知道这是如何不同于BREW卸载/我在我做之前尝试做了OpenSSL的升级。我的假设是,这些操作留下了一些“错误”的共享库,这阻止了它的工作。请注意,这也解决了安装python密码模块的问题。

+4

我得到这个错误:'拒绝链接:openssl' – Flimm 2016-10-11 09:58:20

150

为寻找在MacOS塞拉利昂10.12了一个解决方案:我解决了这个问题通过安装命令行工具:

xcode-select --install 

之后,pip install psycopg2应该工作。

如果没有,你也可以尝试针对BREW的OpenSSL的链接:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2 

通过BREW安装了OpenSSL。需要注意的是brew link openssl --force不起作用了:

$ brew link openssl --force                     17.5s 
Warning: Refusing to link: openssl 
Linking keg-only openssl means you may end up linking against the insecure, 
deprecated system OpenSSL while using the headers from Homebrew's openssl. 
Instead, pass the full include/library paths to your compiler e.g.: 
    -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib 

由于@macho指出,如果以下这仍然无法正常工作,您可能需要使用PIP,例如的--no-cache选项

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install psycopg2 
+0

我一直在为此苦苦挣扎,并持续很长一段时间!非常感谢!!! – 2016-09-01 15:10:03

+5

实际上''xcode-select --install'可能就够了,应该使用'ssl'提供的系统。我会在上面更新我的评论。 – sas 2016-09-02 09:08:42

+6

xcode-select install对于系统python来说已经足够了。但它不适用于虚拟环境。 – 2016-09-02 22:35:21

5

当运行brew link openssl我得到以下信息:

$ brew link openssl 
Warning: Refusing to link: openssl 
Linking keg-only openssl means you may end up linking against the insecure, 
deprecated system OpenSSL while using the headers from Homebrew's openssl. 
Instead, pass the full include/library paths to your compiler e.g.: 
    -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib 

这里根据这一建议是在pip命令你需要使用:

$ pip install -r requirements.txt --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"