安装psycopg2失败的python 3.7

安装psycopg2失败的python 3.7,python,django,python-3.x,heroku,python-3.7,Python,Django,Python 3.x,Heroku,Python 3.7,我正在学习本教程- 到目前为止,我已经: 构建了我的Django应用程序并在本地运行-效果非常好 编写了包含内容的proc文件 web:gunicorn项目名称.wsgi 已将django_heroku导入设置 我需要安装psycopg2,所以我运行了pip安装psycopg2 但是得到了错误 Building wheels for collected packages: psycopg2 Building wheel for psycopg2 (setup.py) ... error

我正在学习本教程-

到目前为止,我已经:

  • 构建了我的Django应用程序并在本地运行-效果非常好
  • 编写了包含内容的proc文件
    web:gunicorn项目名称.wsgi
  • 已将django_heroku导入设置
我需要安装psycopg2,所以我运行了
pip安装psycopg2

但是得到了错误

Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/niamhtohill/ios_dev/vf_api/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-wheel-3u2cfbpc --python-tag cp37
       cwd: /private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/
  Complete output (144 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.7
  creating build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_json.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/extras.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/compat.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/errorcodes.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/tz.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_range.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_ipaddress.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/_lru_cache.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/extensions.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/errors.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/sql.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  copying lib/pool.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
  running build_ext
  building 'psycopg2._psycopg' extension
  creating build/temp.macosx-10.9-x86_64-3.7
  creating build/temp.macosx-10.9-x86_64-3.7/psycopg
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100005 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/Cellar/postgresql/10.5/include -I/usr/local/Cellar/postgresql/10.5/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100005 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/Cellar/postgresql/10.5/include -I/usr/local/Cellar/postgresql/10.5/include/server -c psycopg/green.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/green.o
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100005 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/Cellar/postgresql/10.5/include -I/usr/local/Cellar/postgresql/10.5/include/server -c psycopg/pqpath.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/pqpath.o
  psycopg/pqpath.c:135:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]
                  PQstatus(conn->pgconn) : PQresultStatus(*pgres)));
                  ^~~~~~~~~~~~~~~~~~~~~~
  psycopg/pqpath.c:1712:11: warning: code will never be executed [-Wunreachable-code]
      ret = 1;
            ^
  psycopg/pqpath.c:1817:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]
                  PQstatus(curs->conn->pgconn) : PQresultStatus(curs->pgres)));
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

...
...
....
...
...
...
...
...
...

/adapter_qstring.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols_proto.o build/temp.macosx-10.9-x86_64-3.7/psycopg/typecast.o -L/usr/local/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/psycopg2/_psycopg.cpython-37m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/niamhtohill/ios_dev/vf_api/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-install-q5q1ago2/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/kk/0xnrjqj950qdky6pkv1dws4r0000gn/T/pip-record-t0kpmijs/install-record.txt --single-version-externally-managed --compile --install-headers /Users/niamhtohill/ios_dev/vf_api/venv/bin/../include/site/python3.7/psycopg2 Check the logs for full command output.
我真的觉得我在兜圈子!已经尝试了10次了


请尝试运行pip install psycopg2 binarypsycopg2是一个包装器,因此需要先安装该库(以及其他库),然后才能成功运行
pip install psycopg2
。您看到的错误可能与此有关

还有另一种选择,那就是使用
psycopg2 binary
包,它与自己版本的C库(包括
libpq
)一起预先打包,这意味着您不需要完成所有必要的步骤

$ pip install psycopg2-binary
唯一值得注意的是,不建议在生产环境中使用
psycopg2二进制文件。

这对我来说很有效:

pip安装psycopg2二进制文件--用户

您使用的是Mac电脑吗?您使用的是虚拟环境吗?为什么标记为?在运行Mojave的Mac和虚拟环境中,这可能与“是”重复。这是用于部署到Heroku的,如链接教程中所述。步骤是git push heroku masterI请求解释。