LoginSignup
6
2

More than 1 year has passed since last update.

【python-dotenv】インストールエラー(pip install)

Last updated at Posted at 2022-03-16

環境

  • Python 3.9
  • GNU bash 5.0.17(1)-release (x86_64-pc-linux-gnu)
  • PythonAnywhere

現象

bash
pip install python-dotenv  # 通常
pip install --user python-dotenv  # ユーザ権限(Pythonanywhereの場合も)

原因

ライブラリのインストールは、ビルド済みのファイルが準備されているおかげで通常はスムーズにインストールできる。
しかし、Pythonのバージョンがアップグレードしたばかりの時点では、まだビルド済みのファイルが準備されていない場合がある。そのときは、pip install ではソースをダウンロードしてビルドするが、パソコンにビルドできる環境がないとエラーにる。(pip installでエラーになりインストールできない場合(Windows)より)

解決策

1つ前のバージョンのPythonを使用するのが一番簡単である。例えば、Python3.9 がリリースされてNumPyのインストールに失敗する場合は、既にPython3.8 がインストール済みであれば、python3.8 -m pip install NumPy により Python3.8 にインストールする。(pip installでエラーになりインストールできない場合(Windows)より)

bash
python3.8 -m pip install python-dotenv  # 通常
python3.8 -m pip --user install python-dotenv  # ユーザ権限(Pythonanywhereの場合も)

参考

6
2
1

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
6
2