subprocesspython-3.4whoisfile-not-foundwindows64

Issue with whois and subprocess (Python 3.4; 64-bit Windows)


So I'm just trying to get the suggested query (domain = whois.query("google.com")) working. But whenever I run it, I get the following traceback:

File "file.py", line x, in weight_sources
    domain = whois.query("google.com")
  File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\__init__.py", line 50, in query
    pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
  File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 44, in do_query
    _do_whois_query(dl, ignore_returncode),
  File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 58, in _do_whois_query
    p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 856, in __init__
    restore_signals, start_new_session)
  File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I've seen some other questions/answers point to line 1111 in subprocess, but I think the issue might be in whois as I have used subprocess extensively without error on my device. Since the non-existent file seems to be related to the whois package, I don't think this question is related to this one, although the two could be related?

Essentially, is there any work around for this error or if I need to edit the whois package code, how would I go about that? I'm not exactly sure I even fully understand what "file" is missing...


Solution

  • The missing file is the whois executable, which is opened here:

    subprocess.Popen(['whois', '.'.join(dl)]
    

    The package description says whois is a wrapper for the Linux whois command. That means you must be running on Linux and have whois installed, but you are running Windows.

    So I think you're out of luck with this package, maybe another one (such as python-whois) supports Windows.