试图在python 2.7的macosx 10.14.6上安装psycopg2

问题描述 投票:0回答:1

我做了wget bootstrap.pypa.io/ez_setup.py --no-check-certificate须藤python ez_setup.py须藤-H pip install psycopg2并出现以下错误。

sudo -H pip install psycopg2
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Collecting psycopg2
  Using cached psycopg2-2.8.5.tar.gz (380 kB)
Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-cnW8Dg/psycopg2/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-cnW8Dg/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/tmp/pip-wheel-rthf3D
       cwd: /private/tmp/pip-install-cnW8Dg/psycopg2/
  Complete output (279 lines):
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
    warnings.warn(msg)
  /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.14-intel-2.7
  creating build/lib.macosx-10.14-intel-2.7/psycopg2
  copying lib/_json.py -> build/lib.macosx-10.14-intel-2.7/psycopg2
  copying lib/extras.py -> build/lib.macosx-10.14-intel-2.7/psycopg2

我该如何解决?

postgresql python-2.7 psycopg2
1个回答
0
投票

我尝试过:brew重新安装opensslpip install psycopg2-binary而不是pip install psycopg2。

并且有效。

python
Python 2.7.16 (default, Dec  3 2019, 07:02:07)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> conn = psycopg2.connect(host="localhost",database="postgres", user="appadmin", password="pass1")
>>> cur = conn.cursor()
>>> print('PostgreSQL database version:')
PostgreSQL database version:
>>> cur.execute('SELECT version()')
>>> db_version = cur.fetchone()
>>> print(db_version)
('PostgreSQL 10.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.3, 64-bit',)
>>> cur.close()
© www.soinside.com 2019 - 2024. All rights reserved.