Network Scanner - can't get Scapy running in Python3

Hi,

I am going through Zaid’s ‘Learn Python & Ethical Hacking from Scratch’ course and can’t get the Network Scanner running with Python 3.

I ran the '‘pip3 install scapy-python3’ cmd as he does.

I run it from the cmd line like so ‘python3 network_scanner.py --target 10.0.2.1/24’ and get this
message:

    **PIP package scapy-python3 used to provide scapy3k, which was a fork from scapy implementing python3 compatibility since 2016. This package was included in some of the Linux distros under name of python3-scapy. Starting from scapy version 2.4 (released in March, 2018) mainstream scapy supports python3. To reduce any confusion scapy3k was renamed to kamene. **

**You should use either pip package kamene for scapy3k (see http://github.com/phaethon/kamene for differences in use) or mainstream scapy (pip package scapy, http://github.com/secdev/scapy). **

Traceback (most recent call last):
** File “network_scanner.py”, line 3, in **
** import scapy.all as scapy**
** File “/usr/local/lib/python3.7/dist-packages/scapy/all.py”, line 5, in **
** raise Exception(msg)**
**Exception: **
** PIP package scapy-python3 used to provide scapy3k, which was a fork from scapy implementing python3 compatibility since 2016. This package was included in some of the Linux distros under name of python3-scapy. Starting from scapy version 2.4 (released in March, 2018) mainstream scapy supports python3. To reduce any confusion scapy3k was renamed to kamene. **
You should use either pip package kamene for scapy3k (see http://github.com/phaethon/kamene for differences in use) or mainstream scapy (pip package scapy, http://github.com/secdev/scapy).

It runs fine with Python 2.

Any suggestions?

Thanks

I would suggest installing scapy as shown in their official docs. It works for python 2 and 3 both. https://scapy.readthedocs.io/en/latest/installation.html#installing-scapy-v2-x. Also, I would suggest you to install both the python versions in different virtual environments. Maybe use anaconda and install both in different versions, it’s pretty easy.

Hi @Apurv-StationX,

Thanks for your reply and suggestions.

A few questions based on your suggestions:

  1. I installed the latest version of scapy (2.4.4) using the official docs. I ran the Network Scanner again like so ‘python3 network_scanner.py --target 10.0.2.1/24’, but am still getting an error message:

Traceback (most recent call last):
File “network_scanner.py”, line 3, in
import scapy.all as scapy
ModuleNotFoundError: No module named ‘scapy.all’

It’s clearly still not finding Scapy. I ran ‘pip list’ to confirm that scapy installed and it is listed. Any further suggestions?

  1. You suggest I install both the python versions in different virtual environments. What do you mean by virtual environments exactly? Do you mean different virtual machines or different IDE’s?

  2. I’ve never used Anaconda yet. Is this an IDE? Can it be used with PyCharm? It seems to let you manage different versions.

Hi @Apurv-StationX,

Quick update…

I went and researched Anaconda and I’ve managed to install Anaconda and also created two different environments. One for Python 2.7 and another for Python 3.8. I have also installed scapy in each of the environments as well and now the Network Scanner works great without any errors in both environments. So, thank you for this suggestion. I was wondering how it was possible to maintain all these different Python versions as it was getting incredibly messy…

How do you update scapy to the latest version in each environment in Anaconda though? I’ve noticed that Anaconda has installed v2.4.3 of scapy in both environments. The latest version of scapy is v2.4.4. I have run ‘conda update scapy’ from the conda terminal prompt, but it doesn’t update to v2.4.4. It stays at v2.4.3.

Thanks again.

HI, it’s good that everything is working now with the anaconda. For updating scapy you can manually install the updated version using pip inside anaconda itself

1 Like

Hi @Apurv-StationX,

That worked great. Thanks again for your help.

Simon

Hi @Apurv-StationX,

Actually just noticed, after running ‘pip install scapy’, I’ve noticed that this has updated the base environment of Anaconda’s scapy to 2.4.4 (latest) only. It did not update my other environments scapy versions (Python2.7 & 3.8). I’ve changed environment in Anaconda via the command line using ‘conda activate [environment name]’ and ran ‘pip install scapy’ in both environments but no success. Scapy versions remain at 2.4.3.

The message I get is ‘requirement already satisfied’. Any further suggestions?

Thanks again,

Simon

I don’t know about that tbh. I haven’t updated my tools in every environment like this.

1 Like

Not to worry. v.2.4.3 should suffice.

If I find out how to, I’ll let you know.

Thanks again.

Simon