我目前正在尝试用pyinstaller构建一个应用程序。我得到了错误的The 'google-api-python-client' distribution was not found and is required by the application,我完全失去了原因。
运行pip show google-api-python-client结果
Name: google-api-python-client
Version: 1.8.2
Summary: Google API Client Library for Python
Home-page: http://github.com/google/google-api-python-client/
Author: Google LLC
Author-email: googleapis-packages@google.com
License: Apache 2.0
Location: c:\dev\software\schoology_scrape\schoology_scrape_venv\lib\site-packages
Requires: google-auth-httplib2, uritemplate, google-auth, google-api-core, httplib2, six
Required-by:我还有一个requirements.txt文件,其中包含项目中使用的所有库
任何帮助都将不胜感激!
发布于 2020-04-30 19:28:50
从字面上说,这是在windows上遇到的问题,而macOS则没有问题。我在和fbs和PyQt5一起建房子。
问题
google-api-python-client不是python模块,而是资源,这意味着您不能将它作为隐藏导入注入。googleapiclient.model将google-api-python-client文件夹中的分发信息作为打包资源读取。
您的全部错误可能更接近于此:
...
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\googleapiclient\http.py", line 67, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\googleapiclient\model.py", line 36, in <module>
File "site-packages\pkg_resources\__init__.py", line 479, in get_distribution
File "site-packages\pkg_resources\__init__.py", line 355, in get_provider
File "site-packages\pkg_resources\__init__.py", line 898, in require
File "site-packages\pkg_resources\__init__.py", line 784, in resolve
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application使用fbs或其他通用打包框架的解决方案1- If
google_api_python_client-*/ <pythonInstallLocation>/lib/site-packages/的某个地方
google_api_python_client-*/复制到应用程序的src资源目录中。对于fbs,这可以是:src/freeze/windows/ (推荐),或src/resources/windows/
现在,当您fbs freeze并随后fbs installer您的应用程序时,google_api_python_client-*/将与其他googleapiclient python库一起包含在构建的应用程序目录中,并且错误应该消失。
解决方案2-没有自动包装挂钩(未经测试):
如果您的打包解决方案没有上面类似的钩子,那么:
google_api_python_client-*/文件夹从<pythonInstallLocation>/lib/site-packages/复制到构建的应用程序目录中(或者在编译的python脚本试图访问google-api-python-client的任何地方)。pythonfbs冰冻google python-client
发布于 2020-07-23 08:54:34
我在这里找到了解决方案,链接
将google python-client的版本更新为链接中指定的版本(为我工作)
还创建了一个小.bat文件:
pyinstaller --hidden-import="pkg_resources.py2_warn" --hidden-import="googleapiclient" --hidden-import="apiclient" main.py --onefile还要注意:我在虚拟环境中运行了bat文件。
发布于 2021-10-12 19:59:34
我得到了这个错误,并且使用了Serverless框架。要修复,我只需删除serverless.yml中“定制”块中的“瘦:真”选项
https://stackoverflow.com/questions/61510900
复制相似问题