LoginSignup
24
20

More than 1 year has passed since last update.

pipとpip3の違いを調べた

Posted at

結論

pipコマンドはどのPython環境から呼ばれているかわかりにくいため、Python3環境へのパッケージインストールであれば明示的にpip3コマンドを利用しpip3 install <package>とした方が良い。 pip3を利用すれば確実にPython3環境に紐ついているが、pipはマシンの状況に依る。
https://teratail.com/questions/46066

pip/pip3コマンドがどのPython環境のpipコマンドかはpip -Vで確認可能。Pythonのバージョンと環境のパスが出力される。
Pythonなんて一つしか無いよ!」もしくは、「pipコマンドは自分の使いたい環境にしっかり紐ついてます!!」と、わかっている場合はpipでもpip3でもどっちでも良いです。

なおUbuntuの場合は標準でPythonが提供されており、pipもUbuntuが提供するpython3-pipを利用することが推奨されている。

推奨

そもそもpip install <package>ではなくpython3 -m pip install <package>が推奨されている。(python3部分は利用するPython環境へのパスです。Python2なら2です。)

調べたところ

基本的な使い方
パッケージングのための標準ツールはすべてコマンドラインから使われることを想定しています。
python -m pip install SomePackage

Usage
Unix/macOS
python -m pip <command> [options]

python3 コマンドを使わず、pip3 コマンドを使っても実行できますが、初心者の方には python3 -m pip ... の形式をおすすめします。

Unix/macOS
python3 -m pip install "SomeProject"

24
20
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
24
20