无法在Windows上安装psycopg2

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

我在一个已在服务器上安装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数据库呢?

python postgresql psycopg2
3个回答
1
投票

使用this page下载适用于Windows的预构建二进制文件。


0
投票

从这里psycopg2下载win-psycopg版本的python和windows

不要双击要运行的包。相反,使用setuptoolsdistribute中的easy_install。

C:\> easy_install psycopg2-2.6.1.win32-py2.7-pg9.4.4-release.exe

0
投票

对于那些在2019年遇到同样问题的人,现在通过pip安装它的正确方法是:

pip install psycopg2-binary
© www.soinside.com 2019 - 2024. All rights reserved.