我正在使用100,我需要安装"psycopg2".

我做了以下工作:

pip install http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160

我有以下信息:

Downloading/unpacking http://pypi.python.org/packages/source/p/psycopg2/psycopg2
-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
  Downloading psycopg2-2.4.tar.gz (607Kb): 607Kb downloaded
  Running setup.py egg_info for package from http://pypi.python.org/packages/sou
rce/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
    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'.
    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
Storing complete log in C:\Documents and Settings\anlopes\Application Data\pip\p
ip.log

我的问题是,我只需要这样做就能让psycopg2正常工作?

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

推荐答案

100: Since a while back, there are binary wheels f或 Windows in PyPI, so this should no longer be an issue f或 Windows users. Below are solutions f或 Linux, Mac users, since lots of them find this post through web searches.


Option 1

安装psycopg2-binary PyPI包,它有适用于Linux和Mac操作系统的Python轮子.

pip install psycopg2-binary

Option 2

安装从源代码构建psycopg2软件包的必备站点:

Debian/Ubuntu

Python 3

sudo apt install libpq-dev python3-dev

您可能需要为Python 3.8安装python3.8-dev或类似的软件.

Python 2

sudo apt install libpq-dev python-dev

如果这还不够,试试看

sudo apt install build-essential

sudo apt install postgresql-server-dev-all

as well bef或e installing psycopg2 again.

CentOS 6

Banjer's answer

Python相关问答推荐

优化在numpy数组中非零值周围创建缓冲区的函数的性能

GL pygame无法让缓冲区与vertextPointer和colorPointer一起可靠地工作

2维数组9x9,不使用numpy.数组(MutableSequence的子类)

即使在可见的情况下也不相互作用

如何在箱形图中添加绘制线的传奇?

需要计算60,000个坐标之间的距离

我如何使法国在 map 中完全透明的代码?

OR—Tools中CP—SAT求解器的IntVar设置值

梯度下降:简化要素集的运行时间比原始要素集长

如何保持服务器发送的事件连接活动?

SQLAlchemy bindparam在mssql上失败(但在mysql上工作)

如何在FastAPI中为我上传的json文件提供索引ID?

网格基于1.Y轴与2.x轴显示在matplotlib中

如何防止Pandas将索引标为周期?

简单 torch 模型测试:ModuleNotFoundError:没有名为';Ultralytics.yolo';

在第一次调用时使用不同行为的re. sub的最佳方式

Python OPCUA,modbus通信代码运行3小时后出现RuntimeError

Pandas:将值从一列移动到适当的列

如何将列表从a迭代到z-以抓取数据并将其转换为DataFrame?

组颠倒大Pandas 数据帧