LoginSignup
0
0

More than 1 year has passed since last update.

Ubuntu 18.04 で python の venv をインストールしたメモ

Posted at

取りあえず、インストールしようとしたが失敗しました。
ensurepip が利用できないらしい。

$ python3 -m venv myvenv
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: ['/home/mh/djangogirls/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

pip なしで venv をインストールします。

python3 -m venv --without-pip myvenv
cd myvenv

仮想環境を有効化します。‘

$ source bin/activate

仮想環境下において、get-pip をダウンロードします。

(myvenv) mh@my-local-dev-2:~/djangogirls/myvenv$ wget https://bootstrap.pypa.io/get-pip.py
--2021-mm-dd 19:56:57--  https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.88.175, 2a04:4e42:15::175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.88.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1937800 (1.8M) [text/x-python]
Saving to: ‘get-pip.py’

get-pip.py                            100%[======================================================================>]   1.85M  4.88MB/s    in 0.4s    

2021-mm-dd 19:56:57 (4.88 MB/s) - ‘get-pip.py’ saved [1937800/1937800]

get-pip を使って、pip をダウンロード、インストールします。

$ python get-pip.py
Collecting pip
  Downloading pip-21.1.2-py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 3.2 MB/s 
Collecting setuptools
  Downloading setuptools-57.0.0-py3-none-any.whl (821 kB)
     |████████████████████████████████| 821 kB 11.9 MB/s 
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools, pip
Successfully installed pip-21.1.2 setuptools-57.0.0 wheel-0.36.2
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