I have this script from a few months ago which was working fine, but right now it gives me a weird error. The script is a simple one that extract URLs from emails. it is working correctly in my test env but when I export it as an exe file it throws this error:
C:\Users\tyagi\Desktop\Localization_Download.exe
Extracting download links from outlook
Traceback (most recent call last):
File "main.py", line 62, in <module>
File "urlextract\urlextract_core.py", line 97, in __init__
File "urlextract\cachefile.py", line 61, in __init__
File "urlextract\cachefile.py", line 88, in _get_default_cache_file_path
urlextract.cachefile.CacheFileError: Default cache file does not exist
'C:\Users\tyagi\AppData\Local\Temp\_MEI146482\urlextract\data\tlds-alpha-by-domain.txt'!
[7456] Failed to execute script 'main' due to unhandled exception!
This is the script:
##############################################################
# interacting with outlook to fetch the URL & download all the files
#############################################################
print("Extracting download links from outlook")
from win32com.client import Dispatch
outlook = Dispatch("Outlook.Application").GetNamespace("MAPI")
root_folder = outlook.Folders.Item(2)
inbox_folder = root_folder.Folders.Item(2)
localisation_folder = inbox_folder.Folders['localisation']
messages = localisation_folder.items
bodylist = []
for mail in messages:
body_content = mail.body
bodylist.append(body_content)
####### exporting all outlook emails as a text file
with open("Emailfile.txt", 'w') as output:
for row in bodylist:
output.write(str(row) + '\n')
####### extracting target links from that text file
from urlextract import URLExtract
extractor = URLExtract()
finalUrlList = []
with open("Emailfile.txt") as file:
for line in file:
urls = extractor.find_urls(line,True)
finalUrlList.append(urls)
from pandas import DataFrame
df = DataFrame(finalUrlList,columns=['download urls'])
df = df[df['download urls'].notna()]
df.reset_index(drop=True, inplace=True)
running it as an administrator is not an option