LoginSignup
27
15

More than 3 years have passed since last update.

psycopg2 インストールエラー

Posted at
$ pip install psycopg2

でエラー。

エラー内容(抜粋):


 Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  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'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).

背景:
Ubuntu 18.04.4
AWS EC2インスタンス
Django実装のため、仮想環境にpsycopg2インストールしようとしていた。

やったこと。

①以下をインストール

$ pip install psycopg2-binary

→解決せず。

②pg_config がインストールに必要と書いてあるため、あるか確認


pg_config --version

→出力結果。

Command 'pg_config' not found, but can be installed with:

sudo apt install libpq-dev        
sudo apt install postgresql-common

pg-config が見つからないが、以下のコマンドでインストールできるとあったので、

③pg_config をインストール。

$ sudo apt install libpq-dev   

④再度トライしたらインストールできた。

$  pip install psycopg2

参考: https://www.psycopg.org/docs/install.html

エラーメッセージをよく読み→公式ドキュメントを読むのが結局早かった。

27
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
15