Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Mac OS X上安装libpq dev_Python_Django_Postgresql_Psycopg2 - Fatal编程技术网

Python 在Mac OS X上安装libpq dev

Python 在Mac OS X上安装libpq dev,python,django,postgresql,psycopg2,Python,Django,Postgresql,Psycopg2,我正在本地Mac OS X上尝试使用Postgresql后端运行Django。我已使用pip安装了Django: sudo pip install Django 我已经用一个二进制安装程序安装了Postgresql 但是当我尝试安装psycopg2时,我得到一个错误(粘贴在下面),它找不到pg_配置 看起来我应该安装libpq-dev,但我不确定如何安装 我尝试过用MacPorts安装libpqxx,但没有任何效果 如何安装libpg dev?还是我还遗漏了什么 henrietta:~ $ p

我正在本地Mac OS X上尝试使用Postgresql后端运行Django。我已使用pip安装了Django:

sudo pip install Django
我已经用一个二进制安装程序安装了Postgresql

但是当我尝试安装psycopg2时,我得到一个错误(粘贴在下面),它找不到pg_配置

看起来我应该安装
libpq-dev
,但我不确定如何安装

我尝试过用MacPorts安装
libpqxx
,但没有任何效果

如何安装libpg dev?还是我还遗漏了什么

henrietta:~ $ pip install psycopg2
Downloading/unpacking psycopg2
  Downloading psycopg2-2.4.5.tar.gz (719Kb): 719Kb downloaded
  Running setup.py egg_info for package psycopg2
    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 /Users/thomas/.pip/pip.log

只需从源代码安装postgres。我正在Mac OS X上进行此操作。它非常简单:

./configure 
make
sudo make install
当然,您可能需要额外的步骤,如自动启动,或设置配置选项,但我相信这仍然是在Mac OS X上设置最轻松的方式

如果出于某种原因希望避免从源代码处安装,则应查找psycopg2的二进制版本,例如:


因此,我最终遵循了以下建议:

原来我确实安装了
pg config
,但我不得不四处寻找。一旦我把它包括在路径中,一切都很顺利。以下是该链接的片段:

PATH=$PATH:/Library/PostgresPlus/8.3/bin/ sudo easy_install psycopg2

我使用了
pip
而不是
easy\u install
,我的PostgreSQL安装目录略有不同,但这就是要点。

对于OSX 10.9.2小牛来说,这对我来说是有效的。首先尝试使用brew安装postgres:

brew install postgresql
然后安装pg

gem install pg

在mavericks上的postgress.app中,文件
pg_config
位于
/Applications/Postgres.app/Contents/MacOS/bin/
中,因此我通过以下方式修复了该问题:

sudo PATH=$PATH:/Applications/Postgres.app/Contents/MacOS/bin/ pip install psycopg2

使用macports,这对我来说很有用:

sudo port install postgresql96
sudo port select --set postgresql postgresql96

我相信这会安装所有的postgres客户端工具和LIB,而macports有一个单独的端口用于安装服务器,即
postgresql96 server

如果您只是试图安装
psycopg2
以在mac for Django或Flask等设备上运行,请使用:

pip install psycopg2-binary

从文件上看

这对我来说还行。OSX Maverick with Postgres.app 9.2.2.0:PATH=$PATH:/Applications/Postgres.app/Contents/MacOS/bin pip安装psycopg2用于OSX Mav with Postgres.app 9.3.2.0 RC2
sudo PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin pip安装psycopg2的更新也找不到
/bin
。该目录应该有什么?使用Postgres 9.3
PATH=$PATH:/Library/PostgreSQL/9.3/bin/pip install psycopg2更新OSX Mav这非常有用。非常感谢!要在El Capitan上实现这一点,您需要使用稍微不同的路径
sudo PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin/pip安装psycopg2
我不得不做
brew链接postgresql@9.4--强制执行
,以便gem可以找到
pg\u配置
二进制文件
pip install psycopg2-binary