achillean / shodan-python

The official Python library for Shodan
https://developer.shodan.io
Other
2.5k stars 559 forks source link

ImportError: cannot import name 'Shodan' from 'shodan' #158

Closed omega71044 closed 3 years ago

omega71044 commented 3 years ago

When the following code is executed in visual studio code

from shodan import Shodan api = Shodan('my-api-key') ipinfo = api.host('8.8.8.8') print(ipinfo)

it throws the following error ImportError: cannot import name 'Shodan' from 'shodan'

Please help

PIP LIST Package Version


aniso8601 9.0.1 certifi 2021.5.30 charset-normalizer 2.0.4 click 8.0.1 click-plugins 1.1.1 colorama 0.4.4 Flask 2.0.1 Flask-RESTful 0.3.9 idna 3.2 itsdangerous 2.0.1 Jinja2 3.0.1 MarkupSafe 2.0.1 pip 21.2.3 pytz 2021.1 requests 2.26.0 setuptools 41.2.0 shodan 1.25.0 six 1.16.0 urllib3 1.26.6 Werkzeug 2.0.1 XlsxWriter 2.0.0

sebix commented 3 years ago

Do you have a file in your working directory which is called shodan.py? If yes, rename it to something else, it must not clash with module names

omega71044 commented 3 years ago

Thanks it did work. how did you know?

sebix commented 3 years ago

Because I hacked into your computer ;)

That's a very common error, you'll find lot's of these reports all over the internet, concerning different libraries. Please close the issue if that's now solved, thanks.

achillean commented 3 years ago

Thank you for the help @sebix