【问题标题】:Installing psycopg2 osx 10.12 python 3.5.2 - Failed building wheel for psycopg2安装 psycopg2 osx 10.12 python 3.5.2 - psycopg2 的构建轮失败
【发布时间】:2017-03-14 03:42:59
【问题描述】:

我在 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

感谢您提供的任何帮助!

【问题讨论】:

  • 这似乎是 Homebrew 更新 for OSX sierra 的问题。我终于能够通过使用自制软件卸载并重新安装 python 3.5 和 postgresql 然后尝试再次安装 psycopg2 来解决这个问题。

标签: python macos postgresql psycopg2 python-3.5


【解决方案1】:

macosx sierra 我的方式

全局安装psycopg2,然后在virtualenv中使用

pip3 install psycopg2
workon my_env #i use virtualenvwrapper
toggleglobalsitepackages #Enable global site-packages

就我而言,psycopg2 通常作为全局包安装,但未安装在 virtualenv 中

【讨论】:

  • 在重新安装 python3 和 postgresql 之前,我也无法全局安装 psycopg2。现在它已全局安装,我可以像您描述的那样在 venv 中访问它。谢谢!
【解决方案2】:

我的在 Sierra 10.12.2 更新中坏了。重新安装/更新了命令行工具并正确安装了 psycopg2。

xcode-select --install

【讨论】:

    【解决方案3】:

    这似乎是 Homebrew 的 OSX sierra 更新的问题。我终于能够通过使用自制软件卸载并重新安装 python 3.5 和 postgresql 并尝试再次安装 psycopg2 来解决此问题。

    【讨论】:

      猜你喜欢
      • 2021-01-28
      • 2020-09-07
      • 1970-01-01
      • 2020-01-03
      • 2021-04-25
      • 2020-03-31
      • 1970-01-01
      • 2020-05-31
      • 2016-03-22
      相关资源
      最近更新 更多