Error ModuleNotFoundError: No module named 'whois.whois'

Error ModuleNotFoundError: No module named 'whois.whois'

我收到此错误消息

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

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

我已经安装了所有 whois 包

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

即使我将第 2 行更改为 域 = whois.query('google.com') 我仍然得到同样的错误。

我尝试使用 easy -install.py 但没有成功。

但是如果我 运行 在 Cmd 提示符中只是 whois google.com 我会得到结果。但不在 python 脚本中,即使安装了软件包。

使用 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\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': ['abusecomplaints@markmonitor.com', 'whoisrequest@markmonitor.com'], 'dnssec': 'unsigned', 'name': None, 'org': 'Google LLC', 'address': None, 'city': None, 'state': 'CA', 'zipcode': None, 'country': 'US'}