目指せホワイトハッカー

目指せホワイトハッカー

ホワイトハッカーを目指し勉強中であり、自分の頭の整理のために纏めるのが主目的。ホワイトハッカー以外にも気が向いたら徒然なるままに。

No module named pip エラー 時の対応方法 by Kali linux

No module named pip エラー 時の対応方法 on Kali linux 備忘録


環境

PC:Kali linux 2020.1 on Virtual Box / Windows10

そもそもpipとは

qiita.com

実行コマンドとpipエラー内容

・ある関連モジュールのインストール実行時のエラー

sudo python3 -m pip install -r xyz.txt
/usr/bin/python3: No module named pip

pipエラー対応方法

・pipを強制的に再インストール

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py --force-reinstall

pipエラー対応の確認方法

pip3 -V
pip 20.2.2 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
もしくは、
python3 -m pip -V
pip 20.2.2 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
上記のようにVersionが表示されればOK!!

その他

pipエラー対策確認時に、

pip -V
とやっちゃうと、
/usr/share/python-wheels/pkg_resources-0.0.0-py3-none-any.whl/pkg_resources/py2_warn.py:21: UserWarning: Setuptools will stop working on Python 2
You are running Setuptools on Python 2, which is no longer supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please follow up at
https://bit.ly/setuptools-py2-warning.
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.pip 20.0.2 from /usr/lib/python2.7/dist-packages/pip (python 2.7)
となり、Python2のpipが実行されるので要注意。