python-nmap execution error (nmap.nmap.PortScannerError)
[ Error message ]
(.venv) gangserver@IDEA-U0530:~/python$ python
Python 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nmap
>>> nmapScan = nmap.PortScanner()
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
nmapScan = nmap.PortScanner()
File "/home/gangserver/python/.venv/lib/python3.14/site-packages/nmap/nmap.py", line 136, in __init__
raise PortScannerError(
f"nmap program was not found in path. PATH is : {os.getenv('PATH')}"
)
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : /home/gangserver/python/.venv/bin:/home/gangserver/.local/bin:/home/gangserver/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/snap/bin'
[ Solution ]
- Install the nmap package from the terminal.
$ sudo apt install nmap
[ Installation log ]
gangserver@IDEA-U0530:~/python$ sudo apt install nmap
[sudo: authenticate] 비밀번호:
설치할 패키지:
nmap
설치할 의존성 패키지:
libblas3 liblinear4 nmap-common
제안하는 패키지:
liblinear-tools liblinear-dev ncat ndiff zenmap
요약:
업그레이드: 0, 설치: 4, 삭제: 0, 업그레이드 안 함: 4
다운로드 크기: 6,525 kB
필요한 공간: 28.4 MB / 103 GB 사용 가능
계속하시겠습니까? [Y/n] y
(... Log omitted ...)
[ Rerun ]
(.venv) gangserver@IDEA-U0530:~/python$ python
Python 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nmap
>>> nmapScan = nmap.PortScanner()
>>>