【问题标题】:Difficulty installing psycopg2 on El Capitan在 El Capitan 上安装 psycopg2 有困难
【发布时间】:2018-11-10 00:06:53
【问题描述】:

在使用“SIP”安装 El Capitan 后,我在使用自制软件和 psycopg2 时遇到了问题。

睡着后,我的 Mac 会随机拒绝登录,需要先重新启动。 Apple Capture Data 应用程序指出自制软件是罪魁祸首。互联网上有一些修复,如果 homebrew 位于那里,则允许用户写入 /usr/local。见http://digitizor.com/fix-homebrew-permissions-osx-el-capitan/

剩下的相关问题是“如何安装 psycopg2”。互联网上有一些修复程序,但它们并没有为我解决问题。

我在 pip install psycopg2

的详细输出末尾得到这个
building 'psycopg2._psycopg' extension
  creating build/temp.macosx-10.11-x86_64-3.5
  creating build/temp.macosx-10.11-x86_64-3.5/psycopg
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.1 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090405 -DHAVE_LO64=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I. -I/usr/local/Cellar/postgresql/9.4.5_2/include -I/usr/local/Cellar/postgresql/9.4.5_2/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.11-x86_64-3.5/psycopg/psycopgmodule.o

  clang: error: no such file or directory: 'arch'
  clang: error: no such file or directory: 'x86_64'
  error: command 'clang' failed with exit status 1

Command "/usr/local/opt/python3/bin/python3.5 -c "import setuptools, tokenize;__file__='/private/var/folders/bj/chzjff753fz0hr1l5r9kcc1c0000gn/T/pip-build-h9jxgxsp/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/bj/chzjff753fz0hr1l5r9kcc1c0000gn/T/pip-2uer9v1a-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/bj/chzjff753fz0hr1l5r9kcc1c0000gn/T/pip-build-h9jxgxsp/psycopg2

【问题讨论】:

    标签: python macos postgresql


    【解决方案1】:

    关于第一个问题,随机需要重新启动系统,困难在于 El Captain 明显无法处理两个以上的蓝牙设备。我使用的是触摸板、鼠标和键盘。鼠标或触摸板不得不去。问题消失了!

    Apple 首先建议 Homebrew 是问题所在,然后是 CleanMyMac。不是这样!

    第二期待定...

    【讨论】:

      【解决方案2】:

      您可能喜欢使用 Conda 安装预编译的 psycopg2,而不是立即处理这个自制程序问题。

      安装 Conda:

      wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
      bash Miniconda3-latest-MacOSX-x86_64.sh -b
      

      然后,使用 Python 3.5 和 psycopg2 创建一个名为“postgres”的 Conda 环境:

      conda create -n postgres python=3.5 psycopg2
      

      从这里,使用source activate postgres 激活这个 Conda 环境,您就可以访问 psycopg2。

      MyMachine:~ username$ source activate postgres
      discarding /Users/username/miniconda/bin from PATH
      prepending /Users/username/miniconda/envs/postgres/bin to PATH
      (postgres)MyMachine:~ username$ python
      Python 3.5.0 |Continuum Analytics, Inc.| (default, Sep 13 2015, 10:37:42) 
      [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import psycopg2
      >>> conn = psycopg2.connect("dbname='template1' user='username' host='localhost'")
      >>> conn
      <connection object at 0x1026143c0; dsn: 'dbname='template1' user='username' host='localhost'', closed: 0>
      

      【讨论】:

        猜你喜欢
        • 2016-06-18
        • 2016-03-11
        • 2018-06-19
        • 1970-01-01
        • 2016-01-20
        • 2019-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多