安装psycopg2 osx 10.12 python 3.5.2 - psycopg2的构建轮失败

时间:2016-11-01 00:49:57

标签: python macos postgresql psycopg2 python-3.5

我在OSX中安装psycopg2时遇到很大麻烦。使用自制软件安装Postgresql 9.5.4_1后,我试图在我的虚拟环境中安装psycopg2: pip install psycopg2

我还使用PATH=$PATH:/usr/local/Cellar/postgresql/9.5.4_1/bin/pg_config

将pg_config添加到我的路径中

一旦执行,我会收到一些错误,包括:

  ld: library not found for -lssl


 clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'clang' failed with exit status 1

并且

Failed building wheel for psycopg2

Command "/Users/*username*/.virtualenvs/report/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-build-cuplxne2/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-8gbk007q-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/*username*/.virtualenvs/report/bin/../include/site/python3.5/psycopg2" failed with error code 1 in /private/var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-build-cuplxne2/psycopg2/

尝试从源代码构建会导致类似的错误......

以前的研究和尝试的解决方案:

"Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

How to install Psycopg2 for Python 3.5

How to install psycopg2 with "pip" on Python?

Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system

Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7

感谢您提供的任何帮助!

3 个答案:

答案 0 :(得分:1)

我对macosx sierra的态度

全局安装psycopg2,然后在virtualenv

中使用它
pip3 install psycopg2
workon my_env #i use virtualenvwrapper
toggleglobalsitepackages #Enable global site-packages

在我的情况下,psycopg2通常作为全局包安装,但未在virtualenv中安装

答案 1 :(得分:1)

Mine破坏了Sierra 10.12.2更新。重新安装/更新了正确安装的命令行工具和psycopg2。

xcode-select --install

答案 2 :(得分:0)

这似乎是Homebrew对OSX sierra更新的问题。我能够通过卸载并重新安装python 3.5和postgresql with homebrew ,然后再次尝试安装psycopg2来解决这个问题。