在Ubuntu 14.10上安装psycopg2

时间:2015-12-05 08:51:23

标签: python django postgresql ubuntu pip

在这里完成新手,尝试设置Django以使用PostgreSQL。 我正在使用Ubuntu 14.10,我也安装了PostgreSQL 9.5。
当我在终端中运行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 /tmp/pip-build-la8dJp/psycopg2

我知道包含 pg_config 的目录是/opt/PostgreSQL/9.5/bin/pg_config,但我不知道如何将此目录添加到PATH以安装我的psycopg2。或者安装psycopg2的任何其他方法,以便我可以与我的PostgreSQL进行交互。

提前感谢你。

1 个答案:

答案 0 :(得分:0)

除非您对使用本机postgresql库有严格要求,否则我建议您使用pg8000库,因为这是纯Python。

自从我多年前发现它以来,我就停止使用另一个,忘记了必须在很多平台上编译它。

相关问题