Error installing nmap on repl.it

Hi all,

I’m trying to install python-nmap and nmap on my repl.it project but getting an error.

What I did:
Adding the following to pyproject.toml

[tool.poetry.dependencies]
python = "^3.8"
nmap = "^0.0.1"
python-nmap = "^0.6.1"

Error when running program:

Traceback (most recent call last):
  File "main.py", line 6, in <module>
    ports = port_scanner.get_open_ports("www.freecodecamp.org", [75,85])
  File "/home/runner/fcc-port-scanner/port_scanner.py", line 46, in get_open_ports
    nm = nmap.PortScanner()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nmap/nmap.py", line 129, in __init__
    raise PortScannerError(
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : /home/runner/.apt/usr/bin:/usr/local/go/bin:/opt/virtualenvs/python3/bin:/usr/GNUstep/System/Tools:/usr/GNUstep/Local/Tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

I think nmap is not installed where it’s being searched for… does anyone know how to fix this issue?

Update: I ended up not using nmap for this project and just used socket. No need to answer this question anymore. Thanks.

Also, I realized nmap is a separate program that needs to be downloaded (not just the python library nmap), in case anyone else sees this in the future

1 Like