In this post, I am going to tell you, how you can easily fix the problem of AttributeError: module 'whois' has no attribute 'whois' error.
Python code given below.
➤ Code : whois.py
import whois host = 'google.com' res = whois.whois(host) print(res)
# Struggling with python whois
Swith module to : "pip install whois" to "pip install python-whois"
# python-whois :
-
Create a simple importable Python module which will produce parsed WHOIS data for a given domain.
-
Able to extract data for all the popular TLDs (com, net, org, …)
-
Query a WHOIS server directly instead of going through an intermediate web service like many others do.
-
It Works with Python 2 & 3
Just follow the following steps and fix this problem. So let's see:
-
Step-1 : Unnstall whois module from your distribution(eg: "pip uninstall whois")
pip uninstall whois
-
Step-2 : Now, install python-whois
pip install python-whois
Step-3 : Finally, execute the : "python whois.py" command for windows and, for linux or mac "python3 whois.py"
Note : If there is still a problem then re-start your device and run it again, I hope it work.
Reference : https://pypi.org/project/python-whois
Comments