I am new to python, just started working with it a few weeks ago and as a project I wrote a program to assist agents in my department with host, whois and mx lookups.
Running the program as a .py everything works as intended. But when I convert the .py to an exe using auto_py_to_exe or pyinstaller the host and mx features work but the whois portion fails with the following error:
The DNS query name does not exist: [Errno 2] No such file or directory: 'C:\Users\shawn\AppData\Local\Temp\_MEI109402\whois\data\public_suffix_list.dat'
I am at a loss after searching on my own for answers. I assume I am missing something simple. Any help would be awesome.
My imports:
import PySimpleGUI as sg
import dns.resolver
import socket
import whois
import pywhois
The code in question:
def whois_lookup():
# Get Whois data
try:
hostName = values["-getHost-"]
w = whois.whois(hostName)
tld = hostName.split(".")[-1]
nameservers = dns.resolver.query(hostName, "NS")
if tld == "ca":
window["-textbox-"].print("Registrar: ", w.registrar, "\nExpiration Date: ", w.expiration_date, "\n",)
window["-textbox-"].print("Name Servers: ")
for data in nameservers:
window["-textbox-"].print(data)
else: # same for now but .ca and the other tld's are different in how they display their data.
window["-textbox-"].print("Registrar: ", w.registrar, "\nExpiration Date: ", w.expiration_date, "\n",)
window["-textbox-"].print("Name Servers: ")
for data in nameservers:
window["-textbox-"].print(data)
except Exception as err:
window["-textbox-"].print("The DNS query name does not exist: ", err)
return()
Full code can be found here
autopy output if needed
Running auto-py-to-exe v2.11.0
Building directory: C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae
Provided command: pyinstaller --noconfirm --onefile --windowed --exclude-module "_bootlocale" "C:/Users/shawn/Documents/GitHub/pythonProjects/dnsQuery.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onefile --windowed --exclude-module _bootlocale C:/Users/shawn/Documents/GitHub/pythonProjects/dnsQuery.py --distpath C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\application --workpath C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\build --specpath C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae
48597 INFO: PyInstaller: 4.7
48612 INFO: Python: 3.8.12 (conda)
48632 INFO: Platform: Windows-10-10.0.19042-SP0
48644 INFO: wrote C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\dnsQuery.spec
48665 INFO: UPX is not available.
48681 INFO: Extending PYTHONPATH with paths
['C:\\Users\\shawn\\Documents\\GitHub\\pythonProjects']
49145 INFO: checking Analysis
49147 INFO: Building Analysis because Analysis-00.toc is non existent
49152 INFO: Initializing module dependency graph...
49165 INFO: Caching module graph hooks...
49213 INFO: Analyzing base_library.zip ...
53111 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
53116 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib'
57286 INFO: Caching module dependency graph...
57644 INFO: running Analysis Analysis-00.toc
57685 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Users\shawn\miniconda3\envs\devops\python.exe
58179 INFO: Analyzing C:\Users\shawn\Documents\GitHub\pythonProjects\dnsQuery.py
59293 INFO: Processing pre-find module path hook site from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
59297 INFO: site: retargeting to fake-dir 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\fake-modules'
61684 INFO: Processing module hooks...
61698 INFO: Loading module hook 'hook-dns.rdata.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
65332 INFO: Processing pre-safe import module hook six.moves from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
65705 INFO: Loading module hook 'hook-pycparser.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
65711 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65726 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65731 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65743 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65877 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65890 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65979 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
65990 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
66000 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
66511 INFO: Processing pre-safe import module hook win32com from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
66843 WARNING: Hidden import "pkg_resources.py2_warn" not found!
66850 WARNING: Hidden import "pkg_resources.markers" not found!
66873 INFO: Loading module hook 'hook-setuptools.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
68043 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
68056 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
68062 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
68172 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
68393 INFO: checking Tree
68398 INFO: Building Tree because Tree-00.toc is non existent
68405 INFO: Building Tree Tree-00.toc
68595 INFO: checking Tree
68600 INFO: Building Tree because Tree-01.toc is non existent
68607 INFO: Building Tree Tree-01.toc
68759 INFO: checking Tree
68763 INFO: Building Tree because Tree-02.toc is non existent
68770 INFO: Building Tree Tree-02.toc
68804 INFO: Loading module hook 'hook-Crypto.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
68833 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks'...
68929 INFO: Looking for ctypes DLLs
69058 INFO: Analyzing run-time hooks ...
69083 INFO: Including run-time hook 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
69098 INFO: Including run-time hook 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
69114 INFO: Including run-time hook 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
69127 INFO: Including run-time hook 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
69140 INFO: Including run-time hook 'C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
69174 INFO: Looking for dynamic libraries
69834 INFO: Looking for eggs
69838 INFO: Using Python library C:\Users\shawn\miniconda3\envs\devops\python38.dll
69847 INFO: Found binding redirects:
[]
69866 INFO: Warnings written to C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\build\dnsQuery\warn-dnsQuery.txt
70027 INFO: Graph cross-reference written to C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\build\dnsQuery\xref-dnsQuery.html
70117 INFO: checking PYZ
70126 INFO: Building PYZ because PYZ-00.toc is non existent
70136 INFO: Building PYZ (ZlibArchive) C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\build\dnsQuery\PYZ-00.pyz
71585 INFO: Building PYZ (ZlibArchive) C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\build\dnsQuery\PYZ-00.pyz completed successfully.
71638 INFO: checking PKG
71643 INFO: Building PKG because PKG-00.toc is non existent
71657 INFO: Building PKG (CArchive) dnsQuery.pkg
77419 INFO: Building PKG (CArchive) dnsQuery.pkg completed successfully.
77497 INFO: Bootloader C:\Users\shawn\miniconda3\envs\devops\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
77502 INFO: checking EXE
77519 INFO: Building EXE because EXE-00.toc is non existent
77524 INFO: Building EXE from EXE-00.toc
77536 INFO: Copying bootloader EXE to C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\application\dnsQuery.exe
77652 INFO: Copying icon to EXE
77662 INFO: Copying icons from ['C:\\Users\\shawn\\miniconda3\\envs\\devops\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
77768 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
77776 INFO: Writing RT_ICON 1 resource with 3752 bytes
77786 INFO: Writing RT_ICON 2 resource with 2216 bytes
77796 INFO: Writing RT_ICON 3 resource with 1384 bytes
77818 INFO: Writing RT_ICON 4 resource with 38188 bytes
77833 INFO: Writing RT_ICON 5 resource with 9640 bytes
77839 INFO: Writing RT_ICON 6 resource with 4264 bytes
77845 INFO: Writing RT_ICON 7 resource with 1128 bytes
77858 INFO: Copying 0 resources to EXE
77867 INFO: Emedding manifest in EXE
77881 INFO: Updating manifest in C:\Users\shawn\AppData\Local\Temp\tmpx4w5o9ae\application\dnsQuery.exe
77979 INFO: Updating resource type 24 name 1 language 0
77995 INFO: Appending PKG archive to EXE
84755 INFO: Building EXE from EXE-00.toc completed successfully.
Moving project to: C:\Users\shawn\Desktop
Complete.