Python Forum
Trying to use python-nmap but receiving however python2 or 3 can't find PortScanner. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Trying to use python-nmap but receiving however python2 or 3 can't find PortScanner. (/thread-23829.html)

Pages: 1 2 3


RE: Trying to use python-nmap but receiving however python2 or 3 can't find PortScanner. - snippsat - Jan-19-2020

(Jan-19-2020, 07:09 PM)PythonNmap Wrote: ./ip-get.py
Try not run script like this as it can unclear if it run in Python 2 or 3.
Here for scratch in eg Kail,as my Mint 19 i use pyenv | tutorial then there is no python3 or pip3.
# Test python 3
root@kali-tom:~# python3 -V
Python 3.7.5
root@kali-tom:~# which python3
/usr/bin/python3

# Test pip3
root@kali-tom:~# pip3 -V
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

# Install
root@kali-tom:~# pip3 install python-nmap
Collecting python-nmap
Installing collected packages: python-nmap
Successfully installed python-nmap-0.6.1

# Test that it work
root@kali-tom:~# python3
Python 3.7.5 (default, Oct 27 2019, 15:43:29) 
[GCC 9.2.1 20191022] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nmap
>>> 
>>> nmap.PortScanner
<class 'nmap.nmap.PortScanner'>

# No error it works.
>>> nmap.PortScanner()
<nmap.nmap.PortScanner object at 0x7ff42e2ca6d0>
>>> exit()
Now that all work can run script with python3 ip-get.py.


RE: Trying to use python-nmap but receiving however python2 or 3 can't find PortScanner. - PythonNmap - Jan-19-2020

Nice! That's handy! ( irt pyenv )

Never realized pip3 existed either. This is very helpful!