Python .exe containing alive progress bar error (FileNotFound) - python

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.

Related

TypeError: 'NoneType' object is not callable running exe made with pyinstaller

When trying to run an exe I made using pyinstaller it fails while importing OpenGL with this traceback:
(env) C:\Users\me\myProject>.\dist\myProject\myProject.exe
Traceback (most recent call last):
File "main.py", line 6, in <module>
from igtools import IG
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 "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "OpenGL\GL\__init__.py", line 3, 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 "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "OpenGL\error.py", line 12, 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 "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "OpenGL\platform\__init__.py", line 36, in <module>
File "OpenGL\platform\__init__.py", line 30, in _load
TypeError: 'NoneType' object is not callable
[38272] Failed to execute script 'main' due to unhandled exception!
So I'm not sure exactly what the issue was. It seems like it had something to do with the pyinstaller hooks which I don't fully understand, but I did get it working with this specific combination of release versions:
pyinstaller==4.0
pyinstaller-hooks-contrib==2020.9
PyOpenGL==3.1.5
Maybe this will be helpful if anyone else runs into this.

pyinstaller with tensorflow 1.15 compatability issue? Getting ValueError in compiled app

I'm trying to compile my code that used tensorflow. I've been working with Tensorflow 1.15 although it is compatible with (1.14 and 1.13). Previously had never had issues with pyinstaller but after creating a new conda environment I stopped being able to compile the same code.
To me, it seems like tensorflow and pyinstaller don't play with each other well. I tried a few version combinations and still no luck. I get this error during import tensorlfow statement after compilation. The program runs fine in python 3.7 or python 3.6.
Traceback (most recent call last):
File "my_dir\mv_app.py", line 39, in <module>
from shot_change_detection import shot_change_detection
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 "PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
File "shot_change_detection\shot_change_detection.py", line 42, in <module>
import tensorflow as tf
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 "PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
File "tensorflow\__init__.py", line 99, 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 "PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
File "tensorflow_core\__init__.py", line 28, in <module>
File "<frozen importlib._bootstrap>", line 1019, in _handle_fromlist
File "tensorflow\__init__.py", line 50, in __getattr__
File "tensorflow\__init__.py", line 44, in _load
File "importlib\__init__.py", line 127, in import_module
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
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 "PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
File "tensorflow_core\python\__init__.py", line 52, 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 "PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
File "tensorflow_core\core\framework\graph_pb2.py", line 7, 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 "PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
ValueError: source code string cannot contain null bytes

Python - pyinstaller script not working when executing the .exe

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

ModuleNotFoundError: No module named 'pandas._libs.tslibs.base' in Anaconda

I'm having trouble using the pandas package on Spyder 4.2.1.
Currently using:
MacOS Big Sur ver. 11.2
Python 3.9
Spyder 4.2.1
Anaconda 2020.11
this is the code I'm trying to run:
import pandas as pd
This results in ModuleNotFoundError: No module named 'pandas._libs.tslibs.base' - along with a bunch of other errors.
Full error message:
File "<frozen zipimport>", line 259, in load_module
File "pandas/_libs/tslibs/conversion.pyc", line 14, in <module>
File "pandas/_libs/tslibs/conversion.pyc", line 10, in __load
File "imp.pyc", line 342, in load_dynamic
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1116, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
ModuleNotFoundError: No module named 'pandas._libs.tslibs.base'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 259, in load_module
File "pandas/_libs/missing.pyc", line 14, in <module>
File "pandas/_libs/missing.pyc", line 10, in __load
File "imp.pyc", line 342, in load_dynamic
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1116, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "pandas/_libs/tslibs/__init__.pyc", line 30, 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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 261, in load_module
KeyError: 'pandas._libs.tslibs.conversion'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 259, in load_module
File "pandas/_libs/hashtable.pyc", line 14, in <module>
File "pandas/_libs/hashtable.pyc", line 10, in __load
File "imp.pyc", line 342, in load_dynamic
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1116, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 261, in load_module
KeyError: 'pandas._libs.missing'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 259, in load_module
File "pandas/_libs/interval.pyc", line 14, in <module>
File "pandas/_libs/interval.pyc", line 10, in __load
File "imp.pyc", line 342, in load_dynamic
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1116, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 261, in load_module
KeyError: 'pandas._libs.hashtable'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jack/Downloads/Introduction lab.py", line 78, in <module>
import pandas._libs.tslibs.base
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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "pandas/__init__.pyc", line 30, 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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "pandas/_libs/__init__.pyc", line 13, 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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 261, in load_module
KeyError: 'pandas._libs.interval'
What I've tried so far:
Uninstalling / reinstalling Anaconda (I think I did it correctly?) so
it's on my actual hard disk
Uninstalling/reinstalling the actual pandas module through the terminal
Restarting my Mac
Updating Python to 3.9
Updating Mac to Big Sur
Using import pandas._libs.tslibs.base in my code
Trying to just use import pandaswithoutas pd`
Going to the actual Anaconda files to try to find the error
Using pip uninstall and pip install to try to reinstall the package
Installing miniconda
Using conda install to install the package
FACTORY RESETTING my Mac
None of the above works. Considering literally factory resetting my Mac at this point (just did it, didn't work) because I need this to work for a class I'm taking and even the professor doesn't know how to fix this. For some reason nobody in my class seems to have this issue.
Thank you!
You should not use pip with Anaconda Python. You should use conda instead. So to install something use
conda install name_of_package
Try this and see if it works.
To check that conda is installed, which it should be, type conda -V
Then run conda update conda. You should be ready to go.
When I installed Miniconda and manually imported Pandas, then reinstalled the conda kernel, it suddenly worked. I don't know exactly what I did to trigger it; if someone is more experienced they may be able to explain.

PyInstaller giving error when using Langdetect

I am working on a project which involves doing a language check for an input. When we try to turn it into a .exe file using PyInstaller, it gives away this errors:
C:\Users\luismanj\Allegations_TEF_ARG\dist>.\allegations.exe
Traceback (most recent call last):
File "allegations.py", line 16, 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\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "language_check.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\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\__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\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\detector_factory.py", line 10, 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\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\detector.py", line 9, 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\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\utils\ngram.py", line 23, in <module>
File "langdetect\utils\ngram.py", line 24, in NGram
File "langdetect\utils\messages.py", line 22, in get_string
File "langdetect\utils\messages.py", line 9, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\luismanj\\AppData\\Local\\Temp\\_MEI118322\\langdetect\\utils\\messages.properties'
[22436] Failed to execute script allegations
It seems the main problem as of now is the library Langdetect, which we have been using without issues until now. If anyone knows the cause or has found a workaround for this problem, any comment will be appreciated. Thank you.

Categories

Resources