Python Forum
Why wont this work? - 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: Why wont this work? (/thread-17112.html)



Why wont this work? - ejected - Mar-29-2019

Microsoft Windows [Version 10.0.17134.648]
(c) 2018 Microsoft Corporation. All rights reserved.

(venv) C:\Users\Mario\PycharmProjects\New Project 1>pip3 install nmap
Requirement already satisfied: nmap in c:\users\mario\pycharmprojects\new project 1\venv\lib\site-packages (0.0.1)
You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I'm trying to use nmap in a python script. When I try to install it, it says that I already have nmap installed... So it should work in my python script right? But it's not working. I get this error when I try to use nmap in a script:

(I have "import nmap" at the top of the script)

"C:\Users\Mario\PycharmProjects\New Project 1\venv\Scripts\python.exe" "C:/Users/Mario/PycharmProjects/New Project 1/script.py"
Traceback (most recent call last):
  File "C:/Users/Mario/PycharmProjects/New Project 1/script.py", line 3, in <module>
    ns = nmap.PortScanner()
AttributeError: module 'nmap' has no attribute 'PortScanner'

Process finished with exit code 1



RE: Why wont this work? - ejected - Mar-29-2019

It works in terminal but doesnt work in pycharm?... How do I get it to work in PyCharm?


RE: Why wont this work? - snippsat - Mar-29-2019

(Mar-29-2019, 01:30 AM)ejected Wrote: It works in terminal but doesnt work in pycharm?... How do I get it to work in PyCharm?
You choose the same Python interpreter as in terminal.
So from cmd:
C:\>python -V
Python 3.7.2

C:\>pip -V
pip 19.0.3 from c:\python37\lib\site-packages\pip (python 3.7)
So in this case i would Configure a Python interpreter to be pointing to Python 3.7.