These are the erros when i converted to exe and run it:
Traceback (most recent call last):
File "NoneServerV1.py", line 24, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\glasmor\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pyrebase\__init__.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\glasmor\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pyrebase\pyrebase.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\glasmor\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "gcloud\__init__.py", line 19, in <module>
File "pkg_resources\__init__.py", line 480, in get_distribution
File "pkg_resources\__init__.py", line 356, in get_provider
File "pkg_resources\__init__.py", line 899, in require
File "pkg_resources\__init__.py", line 785, in resolve
pkg_resources.DistributionNotFound: The 'gcloud' distribution was not found and is required by the application
[3108] Failed to execute script NoneServerV1
Maybe someone can help me(I think the problem is with pyrebase bcs i coded a login and auth system with it)
i fixed it by creating in lib/site-packages/pyinstaller/hooks a file called hook-gcloud.py
and i edited it with:
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('gcloud')
If you are using the --onefile switch try to make a build without the switch. This will generate a folder where you can find a smaller exe. Run it and check if you have the same error. In the folder check if the gcloud package exists. It looks like it is not able to find the gcloud package.
If it doesn't exist then use the switch --hidden-import gcloud.
Related
I converted my .py file which contains the alive progress bar package https://pypi.org/project/alive-progress/ into a .exe for windows using the pyinstaller command pyinstaller --console . I however receive an error when I run the program. It runs fine until the alive bar is called and then it prints out the error below.
Traceback (most recent call last):
File "network_nodes_ping.py", line 38, in <module>
File "alive_progress\core\progress.py", line 106, in alive_bar
File "alive_progress\core\configuration.py", line 149, in create_context
File "alive_progress\core\configuration.py", line 183, in lazy_init
File "alive_progress\core\configuration.py", line 14, in _spinner_input_factory
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "alive_progress\styles\__init__.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "alive_progress\styles\exhibit.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "alive_progress\styles\internal.py", line 126, in <module>
File "alive_progress\styles\internal.py", line 12, in create_spinners
File "alive_progress\animations\spinners.py", line 43, in frame_spinner_factory
File "alive_progress\animations\spinners.py", line 43, in <genexpr>
File "alive_progress\animations\spinners.py", line 43, in <genexpr>
File "alive_progress\utils\cells.py", line 145, in to_cells
File "alive_progress\utils\cells.py", line 149, in split_graphemes
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "grapheme\__init.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "grapheme\api.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "grapheme\finder.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "grapheme\grapheme_property_group.py", line 97, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\BRYANV~1\\AppData\\Local\\Temp\\_MEI85082\\grapheme\\data/grapheme_break_property.json'
[13328] Failed to execute script 'network_nodes_ping' due to unhandled exception!
A shorter alternative to what #Pluckerpluck has suggested would be using --collect-data grapheme instead of --add-data <...>.
alive-progress uses a library called grapheme. This library requires a JSON file which you will have to manually specify when using PyInstaller.
In my case, I had it under .venv so the command to make this work was:
pyinstaller -F --add-data ".\.venv\Lib\site-packages\grapheme\data\grapheme_break_property.json;grapheme\data" my_file.py
Note that the argument --add-data takes both a source and a target directory (which we set to grapheme\data)
I will warn you however, that the default terminal doesn't have the fonts capable of actually displaying the progress bar. It works, but it doesn't look pretty. If you run the .exe from a proper terminal though with the font support, it works just fine after this.
So I have been working on a battleship game project in pygame and wanted to start recording game results to help with building an AI. Unfortunately when I go through with this command for pyinstaller:
pyinstaller -D -w -n Battleship -F Gui.py
It goes through and creates the exe with no issue, when I go to launch the exe it throws this error seen in the picture below.
Following that path in the error it seems to be when I call my database script then when I try and import pymongo. If I exclude the database side of my script when I make the exe it runs just find and of course is just missing the database interaction portion.
I am running this through pycharm and it works just fine in this development setting but again when I go to create an exe through pyinstaller it results in the error.
Edit 1: So I have run this now without the -w in cmd window and recieved the following:
C:\Users\14402\SynologyDrive\BattleShip\dist>Battleship.exe
Traceback (most recent call last):
File "Gui.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "DataBase.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pymongo\__init__.py", line 102, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pymongo\collection.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pymongo\common.py", line 42, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "pymongo\compression_support.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "snappy\__init__.py", line 20, in <module>
File "snappy\__init__.py", line 11, in _delvewheel_init_patch_0_0_9
File "os.py", line 1111, in add_dll_directory
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\14402\\AppData\\Local\\Temp\\_MEI1811162\\python_snappy.libs'
[152752] Failed to execute script 'Gui' due to unhandled exception!
Along with this I have checked to see if python-snappy is installed and it is:
PS C:\Users\14402\SynologyDrive\BattleShip> pip install python-snappy
Requirement already satisfied: python-snappy in c:\users\14402\synologydrive\battleship\venv\lib\site-packages (0.6.1)
WARNING: Error parsing requirements for pytz: [Errno 2] No such file or directory: 'c:\\users\\14402\\synologydrive\\battleship\\venv\\lib\\site-packages\\pytz-2022.2.1.dist-info\\METADATA'
Finally I will be going through tomorrow and seeing if I can make a simplified version to see if I can better pinpoint, but from my testing this gets thrown when the exe is starting and hits the import for pymongo.
So after Alexander said they were able to open things and run it no problem. I created a new project and pulled over all the code and reimported the libraries and it ran just fine. I must have something hanging over in my previous project in my library that is causing the problem but it is resolved now! Thank you all for your questions and help, first time posting and it was a bit rough.
I am trying to make a executable of a python script, this script is for use with the google drive api, i have copy and paste the token.pickle file, and the client_secret.json file inside the folder where the .exe is but i have this traceback when i execute the script
Traceback (most recent call last):
File "Myscript.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "googleapiclient\discovery.py", line 68, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "googleapiclient\http.py", line 67, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "googleapiclient\model.py", line 36, in <module>
File "pkg_resources\__init__.py", line 465, in get_distribution
File "pkg_resources\__init__.py", line 341, in get_provider
File "pkg_resources\__init__.py", line 884, in require
File "pkg_resources\__init__.py", line 770, in resolve
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application
[13660] Failed to execute script Myscript
it seems like some modules are not found in the executable , the comand i used to convert the .py file into .exe was
pyinstaller -c -F myscript.py
how can i ensure that the required modules are included in the exe file
You need to add google-api-python-client to the package
I am trying to make an exe. file of my script which is using Nornir automation framework but it is giving the following exception. Can anyone help me in fixing this issue?
File "cli.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "import_functions.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\nornir\__init__.py", line 5, in <module>
File "site-packages\pkg_resources\__init__.py", line 481, in get_distribution
File "site-packages\pkg_resources\__init__.py", line 357, in get_provider
File "site-packages\pkg_resources\__init__.py", line 900, in require
File "site-packages\pkg_resources\__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'nornir' distribution was not found and is required by the application
[50524] Failed to execute script cli ~~~
When I do pyinstaller it executes successfully for python 3.7.
But when I execute the resulting exe I get the result under.
How can I correct this?
dist>mainlocal.exe
Traceback (most recent call last):
File "SpeechChangerLocal\mainlocal.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "d:\home\gitrep\ttt\local\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "lib\site-packages\google\cloud\speech_v1\__init__.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "d:\home\gitrep\ttt\local\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "lib\site-packages\google\cloud\speech_v1\gapic\speech_client.py", line 41, in <module>
File "lib\site-packages\pkg_resources\__init__.py", line 481, in get_distribution
File "lib\site-packages\pkg_resources\__init__.py", line 357, in get_provider
File "lib\site-packages\pkg_resources\__init__.py", line 900, in require
File "lib\site-packages\pkg_resources\__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'google-cloud-speech' distribution was not found and is required by the application
[2900] Failed to execute script mainlocal
I imported google-cloud-speech_v1 instead of google-cloud-speech. Now it works.
I found "When Things Go Wrong" in manual very informative: