Search code examples
python-3.xruntime-errorpywhois

Error ModuleNotFoundError: No module named 'whois.whois'


I get this error saying

 ModuleNotFoundError: No module named 'whois.whois' from https://pypi.org/project/python-whois/

https://pypi.org/project/whois/

I have installed all whois packages

import whois
domain = whois.whois('google.com')
print(domain)

even if I changed line 2 as domain = whois.query('google.com') still I get the same error.

I tried doing using easy -install.py But didn't work.

But if I run just whois google.com in Cmd Prompt I get the results. But not in python script even though the packages are installed.


Solution

  • Install the dependency with pip - "pip install python-whois"

    >>> import whois
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'whois'
    >>>
    
    (base) PS C:\Users\siva> **pip install python-whois**
    Collecting python-whois
      Downloading https://files.pythonhosted.org/packages/3e/32/3a7fa80b485f4a1c41492c062396441f2abf28865bb65d069c228af165f7/python-whois-0.7.1.tar.gz (83kB)
        100% |████████████████████████████████| 92kB 33kB/s
    Requirement already satisfied: future in c:\users\siva\appdata\local\continuum\anaconda3\lib\site-packages (from python-whois) (0.17.1)
    Building wheels for collected packages: python-whois
      Building wheel for python-whois (setup.py) ... done
      Stored in directory: C:\Users\siva\AppData\Local\pip\Cache\wheels\09\69\68\dc484fdb90e36236630beafa07b21644b4280ce3ebd5f8b4b9
    Successfully built python-whois
    Installing collected packages: python-whois
    Successfully installed python-whois-0.7.1
    
    
    (base) PS C:\Users\siva> python
    Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import whois
    >>> w = whois.whois('google.com')
    >>> w
    {'domain_name': ['GOOGLE.COM', 'google.com'], 'registrar': 'MarkMonitor, Inc.', 'whois_server': 'whois.markmonitor.com', 'referral_url': None, 'updated_date': [datetime.datetime(2018, 2, 21, 18, 36, 40), datetime.datetime(2018, 2, 21, 10, 45, 7)], 'creation_date': [datetime.datetime(1997, 9, 15, 4, 0), datetime.datetime(1997, 9, 15, 0, 0)], 'expiration_date': [datetime.datetime(2020, 9, 14, 4, 0), datetime.datetime(2020, 9, 13, 21, 0)], 'name_servers': ['NS1.GOOGLE.COM', 'NS2.GOOGLE.COM', 'NS3.GOOGLE.COM', 'NS4.GOOGLE.COM', 'ns2.google.com', 'ns4.google.com', 'ns3.google.com', 'ns1.google.com'], 'status': ['clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited', 'clientTransferProhibited https://icann.org/epp#clientTransferProhibited', 'clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited', 'serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited', 'serverTransferProhibited https://icann.org/epp#serverTransferProhibited', 'serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited', 'clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)', 'clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)', 'clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)', 'serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)', 'serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)', 'serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)'], 'emails': ['[email protected]', '[email protected]'], 'dnssec': 'unsigned', 'name': None, 'org': 'Google LLC', 'address': None, 'city': None, 'state': 'CA', 'zipcode': None, 'country': 'US'}