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
Related
I am New in Django and GraphQL, following the the article,
I am using python 3.8 in virtual env and 3.10 in windows, but same error occurs on both side, also tried the this Question, i also heard that GraphQL generate queries, But dont know how to generate it, But this error occurs:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/talha/ve/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/talha/ve/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run autoreload.raise_last_exception()
File "/home/talha/ve/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/talha/ve/lib/python3.8/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/home/talha/ve/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/talha/ve/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/talha/ve/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/talha/ve/lib/python3.8/site-packages/django/apps/config.py", line 193, in create
import_module(entry)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
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 "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/talha/ve/lib/python3.8/site-packages/ariadne/__init__.py", line 1, in <module>
from .enums import (
File "/home/talha/ve/lib/python3.8/site-packages/ariadne/enums.py", line 17, in <module>
from graphql.type import GraphQLEnumType, GraphQLNamedType, GraphQLSchema
ModuleNotFoundError: No module named 'graphql.type'```
You can try these following ways,
One, you can find graphql directory in the project, on python path. renaming it will fix the issue.
And also you can try these commands,
pip install pip --upgrade
pip install setuptools --upgrade
pip install gql[all]
Hope this helps, if not please let know. Thanks
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.
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.
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: