导入后,模块who在Python 3中也不起作用

时间:2019-01-16 05:27:27

标签: python python-3.x whois

请检查安装并导入whois模块后获得的以下输出 有人可以帮助解决这个问题吗?

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'
`

1 个答案:

答案 0 :(得分:1)

首先检查是否可以通过此命令whois google.com手动进行whois查找,如果有任何错误,则必须首先使用sudo apt-get install whois安装whois