【发布时间】:2020-10-01 22:37:29
【问题描述】:
我在一个已在服务器上安装 PostgreSQL 的办公室工作。 在我的 Windows 机器上,我安装了 pgAdmin III 1.20 来访问数据库。 我正在尝试在我的 Windows 系统中安装 psycopg2。我收到此错误:
C:\users\Tony> pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\psycopg2.egg-info
writing pip-egg-info\psycopg2.egg-info\PKG-INFO
writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt
writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
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'.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\Tony\appdata\local\temp\pip-build-dobxew\psycopg2
我知道 pg_config 在 PostgreSQL 的 bin 文件夹中可用。但我无法访问服务器中的那个位置。如果没有 pg_config 文件,我无法在本地 Windows 机器上安装 psycopg2。我在某处读到,在构建 psycopg2 时需要 libpq.dll。所以我已将 pgAdmin III 1.20 中存在的 libpq.dll 的路径添加到我的系统路径中。(C:\Program Files (x86)\pgAdmin III\1.20) 那么如何使用Python访问PostgreSQL数据库呢?
【问题讨论】:
-
postgres 安装了吗?
-
@JavierBuzzi 是的 postgres 安装在我正在使用 pgAdmin 客户端访问的服务器中。
标签: python postgresql psycopg2