개발/Python

Ubuntu python-nmap, python3-nmap execution error (PortScannerError)

강서버 2026. 11. 11. 15:44
반응형

[ Error message ]

- python-nmap

(.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'

 

 

- python3-nmap

(.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 nmap3
>>> nmap = nmap3.Nmap()
>>> results = nmap.scan_top_ports("localhost")
Traceback (most recent call last):
  File "<python-input-5>", line 1, in <module>
    results = nmap.scan_top_ports("localhost")
  File "/home/gangserver/python/.venv/lib/python3.14/site-packages/nmap3/nmap3.py", line 156, in scan_top_ports
    output = self.run_command(scan_shlex, timeout=timeout)
  File "/home/gangserver/python/.venv/lib/python3.14/site-packages/nmap3/nmap3.py", line 274, in run_command
    raise NmapNotInstalledError()
nmap3.exceptions.NmapNotInstalledError: Nmap is either not installed or we couldn't locate nmap path Please ensure nmap is installed

 

 

 

[ Solution ]

- Install the nmap package in the Ubuntu 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 ]

- python-nmap

(.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()
>>> 

 

 

- python3-nmap

(.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 nmap3
>>> nmap = nmap3.Nmap()
>>> results = nmap.scan_top_ports("localhost")
>>> 

 

 

반응형
LIST