#目的
Python3とPython2共存環境ではpipを使うとPython2にインストールしてしまう。
Python3を指定してインストールしたい場合は・・・
#結論
paramikoをインストールする場合
[root@test_router ~]# python3 -m pip install paramiko
#例
paramikoのインストールを例にとる
###事前確認
[root@test_router ~]# python3 -m pip list
Package Version
---------- -------
pexpect 4.7.0
pip 19.1.1
ptyprocess 0.6.0
setuptools 39.2.0
###インストール
実際にインストールしてみるとこんな感じ
[root@test_router ~]# python3 -m pip install paramiko
Collecting paramiko
Downloading https://files.pythonhosted.org/packages/17/9f/7430d1ed509e195d5a5bb1a2bda6353a4aa64eb95491f198a17c44e2075c/paramiko-2.5.0-py2.py3-none-any.whl
(198kB)
|????????????????????????????????| 204kB 12.6MB/s
Collecting bcrypt>=3.1.3 (from paramiko)
Downloading https://files.pythonhosted.org/packages/d0/79/79a4d167a31cc206117d9b396926615fa9c1fdbd52017bcced80937ac501/bcrypt-3.1.6-cp34-abi3-manylinux1_x8
6_64.whl (55kB)
|????????????????????????????????| 61kB 27.8MB/s
Collecting cryptography>=2.5 (from paramiko)
Downloading https://files.pythonhosted.org/packages/97/18/c6557f63a6abde34707196fb2cad1c6dc0dbff25a200d5044922496668a4/cryptography-2.7-cp34-abi3-manylinux
1_x86_64.whl (2.3MB)
|????????????????????????????????| 2.3MB 50.5MB/s
Collecting pynacl>=1.0.1 (from paramiko)
Downloading https://files.pythonhosted.org/packages/27/15/2cd0a203f318c2240b42cd9dd13c931ddd61067809fee3479f44f086103e/PyNaCl-1.3.0-cp34-abi3-manylinux1_x8
6_64.whl (759kB)
|????????????????????????????????| 768kB 43.0MB/s
Collecting cffi>=1.1 (from bcrypt>=3.1.3->paramiko)
Downloading https://files.pythonhosted.org/packages/5f/bf/6aa1925384c23ffeb579e97a5569eb9abce41b6310b329352b8252cee1c3/cffi-1.12.3-cp36-cp36m-manylinux1_x8
6_64.whl (430kB)
|????????????????????????????????| 440kB 52.6MB/s
Collecting six>=1.4.1 (from bcrypt>=3.1.3->paramiko)
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=2.5->paramiko)
Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.w
hl (101kB)
|????????????????????????????????| 102kB 29.4MB/s
Collecting pycparser (from cffi>=1.1->bcrypt>=3.1.3->paramiko)
Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB)
|????????????????????????????????| 163kB 40.7MB/s
Installing collected packages: pycparser, cffi, six, bcrypt, asn1crypto, cryptography, pynacl, paramiko
Running setup.py install for pycparser ... done
Successfully installed asn1crypto-0.24.0 bcrypt-3.1.6 cffi-1.12.3 cryptography-2.7 paramiko-2.5.0 pycparser-2.19 pynacl-1.3.0 six-1.12.0
###事後確認
リストにparamikoが含まれていることを確認する
[root@test_router ~]# python3 -m pip list
Package Version
------------ -------
asn1crypto 0.24.0
bcrypt 3.1.6
cffi 1.12.3
cryptography 2.7
paramiko 2.5.0
pexpect 4.7.0
pip 19.1.1
ptyprocess 0.6.0
pycparser 2.19
PyNaCl 1.3.0
setuptools 39.2.0
six 1.12.0
#おわりに
「pip」の前に「python3 -m」忘れずに!