質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

コマンドライン

コマンドライン(別名:Command Line Interface)は、ユーザに命令の入力を促す(プロンプト)文字列の表示を行い、すべての操作をキーボードを用いて文字列を打ち込む事でプログラムを走らせるユーザインターフェースです。

pip

pipとは、Pythonを用いて書かれているパッケージソフトのインストールや管理を行うためのパッケージマネジメントシステムです。pipを使う主なメリットは、コマンドラインインターフェースにて容易にPythonパッケージソフトをインストール可能だという点です。

Q&A

解決済

1回答

2055閲覧

Heroku:pip install gunicorn django-herokuコマンドが実行できない

dbrow

総合スコア18

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

コマンドライン

コマンドライン(別名:Command Line Interface)は、ユーザに命令の入力を促す(プロンプト)文字列の表示を行い、すべての操作をキーボードを用いて文字列を打ち込む事でプログラムを走らせるユーザインターフェースです。

pip

pipとは、Pythonを用いて書かれているパッケージソフトのインストールや管理を行うためのパッケージマネジメントシステムです。pipを使う主なメリットは、コマンドラインインターフェースにて容易にPythonパッケージソフトをインストール可能だという点です。

0グッド

0クリップ

投稿2020/05/05 00:29

実現したいこと

requirements.txt作成に必要となるgunicorn django-herokuのインストール
(参照:https://qiita.com/okoppe8/items/76cdb202eb15aab566d1)

ご質問事項

おそらく下記を実行すれば良いのではないかと思っているのですが、具体的なやり方がわからず、教えていただければ幸いです。

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:

発生している問題・エラーメッセージ

Herokuのコマンドライン経由で実行しようとしているが、以下のエラーが表示される。

Collecting gunicorn Using cached gunicorn-20.0.4-py2.py3-none-any.whl (77 kB) Collecting django-heroku Using cached django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB) Requirement already satisfied: setuptools>=3.0 in ./opt/anaconda3/lib/python3.7/site-packages (from gunicorn) (46.1.3) Collecting django Using cached Django-3.0.6-py3-none-any.whl (7.5 MB) Collecting psycopg2 Using cached psycopg2-2.8.5.tar.gz (380 kB) ERROR: Command errored out with exit status 1: command: /Users/tianbianhongzhi/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-install-usdi9mz4/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-install-usdi9mz4/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-pip-egg-info-t3ko5qrc cwd: /private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-install-usdi9mz4/psycopg2/ Complete output (23 lines): running egg_info creating /private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-pip-egg-info-t3ko5qrc/psycopg2.egg-info writing /private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-pip-egg-info-t3ko5qrc/psycopg2.egg-info/PKG-INFO writing dependency_links to /private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-pip-egg-info-t3ko5qrc/psycopg2.egg-info/dependency_links.txt writing top-level names to /private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-pip-egg-info-t3ko5qrc/psycopg2.egg-info/top_level.txt writing manifest file '/private/var/folders/hs/sqgxt2kx3vscn_0jtt6_pc7h0000gn/T/pip-pip-egg-info-t3ko5qrc/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 <https://www.psycopg.org/docs/install.html>).

コマンド

pip install gunicorn django-heroku

試したこと

・Heroku の Add-onsでPostgresの追加(参照:https://teratail.com/questions/243735)
・pip、setuptoolsのアップデート(参照:https://keymaso.com/programemory/python/pip-error-1/)
・下記インストール(エラー文で言及されていたため)

PyPI'psycopg2-binary' package

補足情報(FW/ツールのバージョンなど)

python3.7.4

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Yasumichi

2020/05/05 00:37

pg_config コマンドが必要ですが、 which pg_config の結果は問題ないのでしょうか?
dbrow

2020/05/05 00:49

which pg_config の結果、特に出力がないです。
Yasumichi

2020/05/05 01:14

PostgreSQL の C 言語用のヘッダーやリンク用のライブラリーの場所を取得するためのコマンドなのですが、Heroku Add-ons に含まれているかは分かりません。 過去の記事だと brew 経由で Postgres を入れて解決したという記事も見かけました。現在も有効かは、分かりません。 heroku 使ってないのに出しゃばって申し訳ありません。
dbrow

2020/05/05 02:23

ありがとうございます。
Yasumichi

2020/05/05 03:30

ヒントにならないかもしれませんが、 Getting Started on Heroku with Python | Heroku Dev Center https://devcenter.heroku.com/articles/getting-started-with-python の手順をやっていったら、勝手に heroku-postgresql がインストールされて、以下のようにデプロイ中に Building wheels for collected packages: psycopg2 Building wheel for psycopg2 (setup.py): started Building wheel for psycopg2 (setup.py): finished with status 'done' Created wheel for psycopg2: filename=psycopg2-2.8.5-cp37-cp37m-linux_x86_64.whl size=454884 のように普通にビルドされてしまいました。
Yasumichi

2020/05/05 03:32

.evn に以下の行があるのが、肝なんですかね? "addons": [ "heroku-postgresql" ],
guest

回答1

0

自己解決

Yasumichi さんにご教示いただいた方法で解決。

投稿2020/05/06 06:51

dbrow

総合スコア18

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問