- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-03-14T05:02:01+00:00","","")
#author("2024-05-02T00:25:05+09:00","","")
#topicpath
////////////////////////////////////////////////////////////////////////////////
* 目次 [#j87cd01d]
#contents();
////////////////////////////////////////////////////////////////////////////////
* pip [#a3187204]
- pip とは、Python のパッケージモジュールを管理するシステム。インストール・アンインストール・一覧表示などが出来る。
- pip には、Python2.x 用と Python3.x 用があり、それぞれのコマンド名は pip, pip3 となる。
//==============================================================================
** pip の install --- OSのパッケージシステムを利用する場合 [#fc0b88c6]
+ debian の場合は以下でインストールする:
# apt-get install python-pip python3-pip
//==============================================================================
** pip の install --- OSのパッケージシステムを利用しない場合 [#u5632228]
+ get-pip.py を入手する
$ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
+ get-pip.py を使って pip3 をインストールする
$ python3 get-pip.py
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
Downloading pip-20.0.2-py2.py3-none-any.whl (1.4 MB)
|████████████████████████████████| 1.4 MB 3.1 MB/s
Collecting setuptools
Downloading setuptools-46.0.0-py3-none-any.whl (582 kB)
|████████████████████████████████| 582 kB 5.5 MB/s
Collecting wheel
Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: pip, setuptools, wheel
WARNING: The scripts pip, pip3 and pip3.5 are installed in '/home/yourname/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts easy_install and easy_install-3.5 are installed in '/home/yourname/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script wheel is installed in '/home/yourname/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.0.2 setuptools-46.0.0 wheel-0.34.2
-- root にならなくても実行出来る。その場合、上記ログのように、 ${HOME}/.local/.bin 以下にインストールされる。
$ ls ~/.local/
bin lib share tmp
$ ls ~/.local/bin
easy_install easy_install-3.5 pip pip3 pip3.5 wheel
$ ls ~/.local/lib/python3.5/site-packages/
__pycache__ pip-20.0.2.dist-info setuptools-46.0.0.dist-info
easy_install.py pkg_resources wheel
pip setuptools wheel-0.34.2.dist-info
+ ${HOME}/.local/bin を環境変数 PATH に加えれば、pip/pip3 が使用可能になる。
//==============================================================================
** pip を使った Python モジュールの管理 [#sf40745f]
- install
$ pip install <パッケージ名>
- uninstall
$ pip uninstall <パッケージ名>
- インストール済みパッケージの一覧表示
$ pip list
//==============================================================================
** バージョンを指定してモジュールをインストールする [#vbc1b1ce]
- pip install では、インストールするモジュールのバージョンを指定できる
- 指定したバージョンでモジュールをインストールする
$ pip install <module>==<version>
-- 例:numpy の version 1.23 をインストールする
$ pip install numpy==1.23
- バージョンの上限を指定してモジュールをインストールする
$ pip install '<module><<latest-version>'
-- 例:numpy の version 1.20 未満の範囲で最新をインストールする
$ pip install 'numpy<1.20'
- バージョンの下限と上限を指定してモジュールをインストールする
$ pip install '<module>>=<oldest-version>,<<latest-version>'
-- 例:numpy の version 1.20 以上 1.23 未満の範囲で最新をインストールする
$ pip install 'numpy>=1.20,<1.23'
//==============================================================================
** どんなバージョンがあるかを知りたい場合 [#r17d722b]
- 調査中