毎回詰まっては試行錯誤して、ずっと根本原因がつかめなかったことが解決できたのでメモを残しておきます。
エラー内容
pip install django-heroku
をおこなうと次のエラーが起こりました。
Collecting psycopg2 Using cached psycopg2-2.8.4.tar.gz (377 kB) ERROR: Command errored out with exit status 1: creating /tmp/pip-install-6kaekgc5/psycopg2/pip-egg-info/psycopg2.egg-info writing /tmp/pip-install-6kaekgc5/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO writing dependency_links to /tmp/pip-install-6kaekgc5/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt writing top-level names to /tmp/pip-install-6kaekgc5/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt writing manifest file '/tmp/pip-install-6kaekgc5/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt' 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>). ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ソースからのpsycopg2のビルドを避けたい場合は、PyPIをインストールしてください
と書いてあるので pip install psycopg2-binary
したあとにpip install django-heroku
しても同じエラーが出ました。
libpq-devのインストール
自分の解決方法は sudo apt install libpq-dev
でした。今回はWSLでまっさらな状態から作ったのでlibpq-dev
がありませんでした。issueに原因解決の方法が載っていたので実行したら無事にpsycopg2
のインストールが出来ました。
ちなみにlibpq-dev
は
PostgreSQLデータベースバックエンドと通信するためにlibpqライブラリとリンクするCプログラムをコンパイルするためのヘッダーファイルと静的ライブラリ。
とDebianのサイトに記述がありました。