LoginSignup
0
1

More than 1 year has passed since last update.

Kali Linuxでpip2を使う

Posted at

書くこと

Kali LinuxでPython2のコードを実行しようとしたときにモジュールがないと言われたので、pipでインストールしようとしたのですが、Python2でpipが使えなかったのでインストールした時の話です。

環境

  • ホストOS: macOS Big Sur 11.5.1
  • ゲストOS: Kali Linux 2021.2
  • Python2: 2.7.18
  • 仮想化ソフト: VirtualBox

pipのインストール

私は最初、pipをインストールするためにhttps://pip.pypa.io/en/stable/installing/ というサイトのget-pip.pyをダウンロードしました。そして、以下のようにget-pip.pyを実行しました。

$ python get-pip.py
ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.

すると、上のようなエラーが出ました。このスクリプトはPython 2.7で動かないようです。

調べると、Python2.7用のget-pip.pyは違う場所に置かれていたようなので、そちらを使うことにしました。

以下のようにコマンドを実行し、インストールをしました。

$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py                                                                                                                     1 ⨯
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1863k  100 1863k    0     0  5716k      0 --:--:-- --:--:-- --:--:-- 5716k

$ python get-pip.py                                                     
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 6.5 MB/s 
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
  WARNING: The scripts pip, pip2 and pip2.7 are installed in '/home/kali/.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/kali/.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.3.4 wheel-0.36.2

ここで、The scripts pip, pip2 and pip2.7 are installed in '/home/kali/.local/bin' which is not on PATH.とあり、pipは/home/kali/.local/binの下にあるようです。

$ ls /home/kali/.local/bin                                                                                                                                                            1 ⨯
pip  pip2  pip2.7  wheel

無事にインストールされていました。

まとめ

最終的に、自分の環境ではpipを使ってモジュールを導入することができました。
次に使うことはないかもしれないです。
pip2を繰り返し使う予定のある方はpipのパスを通しておくと良いかもしれないです。

0
1
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
1