Problem with nmap (AttributeError: module 'nmap' has no attribute 'PortScanner')

Answered

Hi

I use Pycharm and I 've got a problem with the nmpa import

import nmap
nm = nmap.PortScanner()
nm.scan('localhost', arguments= '-S 127.0.0.1')
for host in nm.all_hosts():
print('Host : %s (%s)' % (host, nm[host].hostname()))

Always the same error

nm = nmap.PortScanner()
AttributeError: module 'nmap' has no attribute 'PortScanner'

 

But if I test the code under python launch since a bash console, no error.

I don't know where find an issue

In the 2 cases, it's the same version of python (3.7) and in Pycharm, python-nmap is install.

Any idea ? Thx

0
2 comments

It's most likely not related to PyCharm but to the package itself.

Check which interpreter you use when running it outside of PyCharm and either configure that interpreter in PyCharm or make sure the same version of nmap is installed in PyCharm.

https://intellij-support.jetbrains.com/hc/en-us/articles/360010202240

0
Avatar
Permanently deleted user

OK thanx, just find how to fix this problem

It 's was the venv configuration (not really easy to understand how use them)

I've defined a default virtuel environment , like template for the different projects

Thx again,

Enjoy

0

Please sign in to leave a comment.