Python3で仮想環境作成時にFailing command: [‘/home/user/venv/bin/python’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]が出た時の対処方法

python3がインストールされているのに仮想環境(venv)作成時に以下のエラーが発生する場合があります。

# python -m venv venv
    The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/root/fastapi/fastapi/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']

今回のその場合の解決方法を紹介します。

目次

解決方法

エラーメッセージにある通り、python-venvをインストールすれば解決します。

apt install python3-venv

3.9系はきちんとバージョンを指定する必要がある。

apt install python3.9-venv
よかったらシェアしてね!
  • URLをコピーしました!
目次