0
0

More than 1 year has passed since last update.

【PythonAnywhere・Django】デプロイ時、仮想環境でpip3 installしたモジュールがなぜかないことになっていてデプロイできない問題

Posted at

問題

  • Djangoアプリ内で、pip installが必要なモジュールをimportしている。
  • PythonAnywhereのWeb→「Start a console in this virtualenv」から pip3 install 〇〇 をしたはずなのに、デプロイすると「モジュール見つからん!」って言われる。

原因

デプロイ時に勝手に仮想環境をいじられて(?)しまうっぽい。

解決法

requirements.txtを使用する。

補足

ネットで調べてみると、「仮想環境下でpip3 installする」「requirements.txtを書く」のどちらでも良いように書いているが、私の環境では後者しかうまくいかなかった。
requirements.txtを使用すれば、デプロイ時に仮想環境にインストールしてくれる。こっちのほうがパッケージ追加のときに便利なのでこっちを使おう。

0
0
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
0
0