3

Please Check the following output i get after installing and import whois module can someone help with this issue ?

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import whois
>>> domain = whois.query('www.google.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/whois/__init__.py", line 50, in query
    pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
  File "/usr/local/lib/python3.6/dist-packages/whois/_1_query.py", line 44, in do_query
    _do_whois_query(dl, ignore_returncode),
  File "/usr/local/lib/python3.6/dist-packages/whois/_1_query.py", line 58, in _do_whois_query
    p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'whois': 'whois'
`
IamBatman
  • 85
  • 1
  • 10
  • 1
    The `whois` module is just a wrapper around the `whois` command. From a terminal, can you type `which whois` and see what it finds? – PaSTE Jan 16 '19 at 05:30

2 Answers2

6

First check if you can whois lookup manually by this command whois google.com, if there is any error, you will have to install whois first using sudo apt-get install whois

Tamim
  • 916
  • 11
  • 19
  • Its working now ... but apparently not getting any proper details from it as per my requirement... Can you suggest me an alternative library for whois ? – IamBatman Jan 16 '19 at 05:59
  • There is no other better whois library and whois information are stored in a central whois database so library can't do anything much if database doesn't provide enough information. Due to privacy policy of domain registry and recent GDPR culture, whois server hide most of the whois information of a domain like email / phone / address etc. – Tamim Jan 16 '19 at 06:06
  • "whois information are stored in a central whois database " There is no "whois database". Each registry managing a TLD has a database of its objects, mainly domains, but also contacts, hosts, etc. And whois is a protocol used to query this. There is a central database per TLD, the one managed by the relevant registry. – Patrick Mevzek Jan 17 '19 at 18:55
  • @suyash999 " Can you suggest me an alternative library for whois ?" there are many in many languages, but it is offtopic here to suggest one. However technically, use one that does not need to shell out to a `whois` command on the system as this is mostly useless. whois is just simple exchange over `TCP/43` so the library could open the port itself. – Patrick Mevzek Jan 17 '19 at 18:57
0

I also faced the same issue. I installed the whois library using pip and it was not working. Then I used

sudo apt-get install whois

to re-install the whole module and then it worked fine.

Alessandro Togni
  • 680
  • 1
  • 9
  • 24
Anish R
  • 1
  • 1