3

I tried to execute this code:

import whois
w = whois.whois('webscraping.com')
print w

And I got the error above. Why?

shira stenmetz
  • 297
  • 1
  • 6
  • 11
  • 1
    Check if you are actually importing the package with `print whois.__file__`. That should return something pointing to your `site-packages`. Otherwise, you must be importing something in your current directory that's named `whois`. – Abdou Dec 15 '16 at 14:30
  • I got this C:\Python27\lib\site-packages\whois\__init__.pyc – shira stenmetz Dec 15 '16 at 14:45
  • well that's weird. `w = whois.query('webscraping.com')` should work if you've installed the package properly. I would recommend reinstalling it and trying again. – Abdou Dec 15 '16 at 15:15
  • `print dir(whois)` to see all the methods and attributes from the module. You should be able to spot `query` and such in there. – Abdou Dec 15 '16 at 15:44

2 Answers2

12

Wrong library, solution is to remove old one and install new :

pip uninstall whois 
pip install python-whois
GAD3R
  • 4,317
  • 1
  • 23
  • 34
Oleg S
  • 121
  • 1
  • 3
2

Try this instead:

w = whois.query('webscraping.com')
FelixSFD
  • 6,052
  • 10
  • 43
  • 117