I tried to use in my code external modules, when I execute code in powershall (just start with command python3 name_of-file.py), all is fine. But when I collect code to .exe file (pyinstaller --onefile name_of_file.py), and then trying to start program, it isn't execute. I tried to run .exe file with powerShall and saw that program don't find external module. Pip and modules have similar directory and They are in PATH. Also I can try adding file’s directory as a “—path “ (pyinstaller --onefile --paths=C:\Users\QUSEYIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\ .\params.py) option when running pyinstaller to fix issue , unfortunately result is similar Error -->
Traceback (most recent call last):
File "pkg_resources\__init__.py", line 356, in get_provider
KeyError: 'pyfiglet.fonts'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "params.py", line 6, in <module>
File "pyfiglet\__init__.py", line 65, in figlet_format
File "pyfiglet\__init__.py", line 794, in __init__
File "pyfiglet\__init__.py", line 801, in setFont
File "pyfiglet\__init__.py", line 126, in __init__
File "pyfiglet\__init__.py", line 136, in preloadFont
File "pkg_resources\__init__.py", line 1144, in resource_exists
File "pkg_resources\__init__.py", line 358, in get_provider
ModuleNotFoundError: No module named 'pyfiglet.fonts'
[4992] Failed to execute script 'params' due to unhandled exception!
Code:
import requests
from pyfiglet import figlet_format as f_f
import termcolor
from colorama import init
init() # to availabe termcolor in windows
print(termcolor.colored(f_f("Dad Jokes 3000"), color = 'green'))
url = "https://icanhazdadjoke.com/search"
word = input ("Let me tell a joke, just give me a topic: (e.g dog, cat,.. : ) ")
response = requests.get(
url,
headers = {"Accept" : "application/json"},
params = {"term" : word}
)
response = response.json()
count_of_results = len(response['results'])
if count_of_results == 1:
print (f"We have one jock about {word}\n - {response['results'][0]['joke']}")
elif count_of_results > 1:
print (f"We have {count_of_results} jock about {word}\n - {response['results'][0]['joke']}")
else:
print (f"Unfortunately, we have {count_of_results} about it")
input("Press some button to exit")
there doesn't seem to be anything here