scapy のインストール

chestnut_eared_bunting02 linux

scapy インストール時の作業ログを備忘録として残しておきます。

※ここでは実際に設定、動作したものを掲載していますが、内容について保証するものではありません。流用される場合は各自の責任でお願いします。

scapy の基本的な操作については「scapy の基本的な操作」をご参照ください。

環境は以下のとおりです。

[root@rocky8-client ~]# uname -a
Linux rocky8-client.mydomain 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 17:00:45 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
[root@rocky8-client ~]# cat /etc/redhat-release
Rocky Linux release 8.10 (Green Obsidian)
[root@rocky8-client ~]#

scapy は pip(*1) でインストールします。scapy インストールに先立ち Python をインストールします。

*1 pip は Python のパッケージ管理システムです。

Python3 インストール

Python3.11 が未インストールであること確認します。(インストール済の場合、リポジトリ名の前に@が付きます。)

[root@rocky8-client ~]# dnf list | grep python3.11
python3.11.x86_64                                                 3.11.13-1.el8_10                                            appstream
python3.11-PyMySQL.noarch                                         1.0.2-2.el8_10                                              appstream
python3.11-babel.noarch                                           2.14.0-1.el8                                                epel

- 省略 -

python3.11-wheel.noarch                                           0.38.4-4.el8                                                appstream
python3.11-winrm.noarch                                           0.4.3-1.el8                                                 epel
python3.11-xmltodict.noarch                                       0.12.0-1.el8                                                epel
[root@rocky8-client ~]#

これからインストールする Python3.11 のパッケージの情報を確認します。(備忘録として残しているだけで必須の操作ではありません)

[root@rocky8-client ~]# dnf info python3.11
メタデータの期限切れの最終確認: 0:02:19 前の 2025年07月17日 19時12分13秒 に実施しました。
利用可能なパッケージ
名前         : python3.11
バージョン   : 3.11.13
リリース     : 1.el8_10
Arch         : x86_64
サイズ       : 31 k
ソース       : python3.11-3.11.13-1.el8_10.src.rpm
リポジトリー : appstream
概要         : Version 3.11 of the Python interpreter
URL          : https://www.python.org/
ライセンス   : Python
説明         : Python 3.11 is an accessible, high-level, dynamically typed, interpreted
             : programming language, designed with an emphasis on code readability.
             : It includes an extensive standard library, and has a vast ecosystem of
             : third-party libraries.
             :
             : The python3.11 package provides the "python3.11" executable: the reference
             : interpreter for the Python language, version 3.
             : The majority of its standard library is provided in the python3.11-libs package,
             : which should be installed automatically along with python3.11.
             : The remaining parts of the Python standard library are broken out into the
             : python3.11-tkinter and python3.11-test packages, which may need to be installed
             : separately.
             :
             : Documentation for Python is provided in the python3.11-docs package.
             :
             : Packages containing additional libraries for Python are generally named with
             : the "python3.11-" prefix.
             :
             : For the unversioned "python" executable, see manual page "unversioned-python".

[root@rocky8-client ~]#

Python3.11 をインストールします。

[root@rocky8-client ~]# dnf install python3.11 -y

- 省略 -

インストール済み:
  mpdecimal-2.5.1-3.el8.x86_64                    python3.11-3.11.13-1.el8_10.x86_64        python3.11-libs-3.11.13-1.el8_10.x86_64        python3.11-pip-wheel-22.3.1-5.el8.noarch
  python3.11-setuptools-wheel-65.5.1-3.el8_10.noarch

完了しました!
[root@rocky8-client ~]#

python3.11 用の pip をインストールします。

[root@rocky8-client ~]# dnf install python3.11-pip -y

- 省略 -

インストール済み:
  python3.11-pip-22.3.1-5.el8.noarch              python3.11-setuptools-65.5.1-3.el8_10.noarch

完了しました!
[root@rocky8-client ~]#

バージョンを確認します。

[root@rocky8-client ~]# python3 -V
Python 3.11.13
[root@rocky8-client ~]# pip3 -V
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
[root@rocky8-client ~]#

pip を最新化しておきます。

[root@rocky8-client ~]# python3 -m pip install pip --upgrade
Requirement already satisfied: pip in /usr/lib/python3.11/site-packages (22.3.1)
Collecting pip
  Downloading pip-25.1.1-py3-none-any.whl (1.8 MB)
     ---------------------------------------- 1.8/1.8 MB 2.3 MB/s eta 0:00:00
Installing collected packages: pip
Successfully installed pip-25.1.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@rocky8-client ~]#
[root@rocky8-client ~]# pip3 -V
pip 25.1.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
[root@rocky8-client ~]#

デフォルトで使用される Python のバージョンを確認します。

[root@rocky8-client ~]# update-alternatives --display python3
python3 -ステータスは自動です。
リンクは現在 /usr/bin/python3.11 を指しています。
/usr/bin/python3.11 - 優先度 31100
 スレーブ pip-3: /usr/bin/pip-3.11
 スレーブ pip3: /usr/bin/pip3.11
 スレーブ pydoc-3: /usr/bin/pydoc3.11
 スレーブ pydoc3: /usr/bin/pydoc3.11
 スレーブ python3-man: /usr/share/man/man1/python3.11.1.gz
現在の「最適」バージョンは /usr/bin/python3.11 です。
[root@rocky8-client ~]#

デフォルトのバージョンが 3.11 でなければ以下のコマンドで切り替えます。本環境では古いバージョンはインストールされておらず、切り替えの必要はありませんでした。

update-alternatives --config python3

scapy インストール

pip で scapy をインストールします。

[root@rocky8-client ~]# pip3 install scapy
Collecting scapy
  Downloading scapy-2.6.1-py3-none-any.whl.metadata (5.6 kB)
Downloading scapy-2.6.1-py3-none-any.whl (2.4 MB)
   ---------------------------------------- 2.4/2.4 MB 490.9 kB/s eta 0:00:00
Installing collected packages: scapy
Successfully installed scapy-2.6.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
[root@rocky8-client ~]#

scapy のバージョンを確認します。

[root@rocky8-client ~]# python3 -c "import scapy; print(scapy.__version__)"
2.6.1
[root@rocky8-client ~]#
タイトルとURLをコピーしました