如何在python3中使用pip安装psycopg2



我似乎遇到了问题。我需要在python中使用pip-install db_utils来安装db_util,但要做到这一点,我需要首先使用pip-innstall psycopg2(而不是二进制(。我犯了一些错误,我似乎无法消除。我使用mac并收到以下消息:

1.pip安装psycopg2:

ERROR: Command errored out with exit status 1:
command: /Users/shaansaharan/uraEnv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-install-0rx6_2cr/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-install-0rx6_2cr/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-56e88jv6
cwd: /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-install-0rx6_2cr/psycopg2/
Complete output (23 lines):
running egg_info
creating /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-56e88jv6/psycopg2.egg-info
writing /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-56e88jv6/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-56e88jv6/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-56e88jv6/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-56e88jv6/psycopg2.egg-info/SOURCES.txt'

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:

python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).

----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

2.pip安装db_utils

Collecting db_utils
Using cached db_utils-0.4.6-py3-none-any.whl (24 kB)
Collecting mysql-connector-python>=8.0.15
Using cached mysql_connector_python-8.0.24-py2.py3-none-any.whl (319 kB)
Collecting awscli>=1.16.32
Downloading awscli-1.19.67-py2.py3-none-any.whl (3.6 MB)
|████████████████████████████████| 3.6 MB 20.4 MB/s 
Collecting jinja2>=2.10.1
Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 567 kB/s 
Collecting sqlparse>=0.2.4
Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 1.0 MB/s 
Collecting psycopg2>=2.8.2
Using cached psycopg2-2.8.6.tar.gz (383 kB)
ERROR: Command errored out with exit status 1:
command: /Users/shaansaharan/uraEnv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-install-mp88whx9/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-install-mp88whx9/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-u8n74xr7
cwd: /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-install-mp88whx9/psycopg2/
Complete output (23 lines):
running egg_info
creating /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-u8n74xr7/psycopg2.egg-info
writing /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-u8n74xr7/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-u8n74xr7/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-u8n74xr7/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/sz/qgv_1m8x3jv7vgympqys_mph0000gn/T/pip-pip-egg-info-u8n74xr7/psycopg2.egg-info/SOURCES.txt'

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:

python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).

----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
enter code here

感谢您抽出时间

对于我的情况,我遇到了类似的错误,在运行命令时必须遵循说明

brew link openssl

我希望这对有帮助

您可以安装它的二进制文件:

pip install psycopg2-binary

最新更新