[英]Python pyinstaller error when converting to exe
These are the erros when i converted to exe and run it:这些是我转换为 exe 并运行它时的错误:
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)也许有人可以帮助我(我认为问题出在 pyrebase bcs 上,我用它编写了登录和身份验证系统)
If you are using the --onefile
switch try to make a build without the switch.如果您使用--onefile
开关,请尝试在没有开关的情况下进行构建。 This will generate a folder where you can find a smaller exe.这将生成一个文件夹,您可以在其中找到一个较小的 exe。 Run it and check if you have the same error.运行它并检查是否有相同的错误。 In the folder check if the gcloud package exists.在文件夹中检查 gcloud 包是否存在。 It looks like it is not able to find the gcloud package.好像找不到 gcloud 包。
If it doesn't exist then use the switch --hidden-import gcloud
.如果它不存在,则使用开关--hidden-import gcloud
。
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我通过在 lib/site-packages/pyinstaller/hooks 中创建一个名为 hook-gcloud.py 的文件来修复它,并使用以下命令对其进行了编辑: from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('gcloud') datas = copy_metadata('gcloud')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.