web-dev-qa-db-ja.com

Mac OSXにlibpq-devをインストールします

ローカルのMacOSXでPostgresqlバックエンドを使用してDjangoを実行しようとしています。pipを使用してDjangoをインストールしました:

Sudo pip install Django

バイナリインストーラーの1つを使用してPostgresqlをインストールしました ここ

しかし、psycopg2をインストールしようとすると、pg_configが見つからないというエラー(以下に貼り付け)が表示されます。

から この質問 インストールする必要があるようです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
14
tchaymore

OSX 10.9.2 Mavericksの場合、これが私にとってうまくいったことです。最初にbrewでpostgresをインストールしてみてください:

brew install postgresql

次に、pgをインストールします

gem install pg
21
esilver

だから私はここでアドバイスに従うことになった:

http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/

pg-configがインストールされていたことがわかりましたが、少し掘り下げて見つける必要がありました。それをパスに含めると、すべてが順調に機能しました。そのリンクのスニペットは次のとおりです。

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

easy_installの代わりにpipを使用し、PostgreSQLのインストールディレクトリが少し異なりましたが、それが要点です。

14
tchaymore

ソースからpostgresをインストールするだけです。私はMacOSXでそれを行っています。それは次のように簡単です:

./configure 
make
Sudo make install

もちろん、自動起動や設定オプションの設定などの追加の手順が必要になる場合がありますが、これはMac OSXで設定する最も簡単な方法であると私は信じています。

また、何らかの理由でソースからのインストールを避けたい場合は、psycopg2のバイナリバージョンを探す必要があります。ここ: http://www.initd.org/psycopg/download/

Sudo port install py27-psycopg2
4
kgr

Mavericksのpostgress.appでは、ファイルpg_config/Applications/Postgres.app/Contents/MacOS/bin/にあるので、次のように問題を修正しました。

Sudo PATH=$PATH:/Applications/Postgres.app/Contents/MacOS/bin/ pip install psycopg2
2
pier