找不到'google-api-python-client'分发,使用pyinstaller的应用程序需要该分发 [英] The 'google-api-python-client' distribution was not found and is required by the application with pyinstaller
问题描述
我目前正在尝试使用pyinstaller构建应用.我得到了错误The 'google-api-python-client' distribution was not found and is required by the application
,我完全迷失了原因.
I am currently trying to build an app with pyinstaller. I have gotten the error The 'google-api-python-client' distribution was not found and is required by the application
and I'm completely lost why.
使用
运行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文件,其中包含项目中使用的所有库
I also have a requirements.txt file with all the libraries used in the project
任何帮助将不胜感激!
推荐答案
从字面上看,只是在Windows上遇到了此问题,而macOS可以.我正在使用 fbs 和
Literally just ran into this issue on windows, whereas macOS is okay. I'm building with fbs and PyQt5.
google-api-python-client
不是python模块,而是资源,这意味着您不能将其作为隐藏导入注入. googleapiclient.model
从google-api-python-client
文件夹中读取分发信息作为打包资源.
google-api-python-client
is not a python module, but a resource, which means you cannot inject it as a hidden-import. googleapiclient.model
reads the distribution info from google-api-python-client
folder as a packaged resource.
您的完整错误可能看起来更接近此:
Your full error might look closer to this:
...
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
- 找到
google_api_python_client-*/
- 可能在
<pythonInstallLocation>/lib/site-packages/
- 可能在
- Locate the
google_api_python_client-*/
- likely somewhere
<pythonInstallLocation>/lib/site-packages/
- likely somewhere
-
src/freeze/windows/
(推荐),或 -
src/resources/windows/
src/freeze/windows/
(recommended), orsrc/resources/windows/
现在,当您fbs freeze
以及随后的fbs installer
应用程序时,google_api_python_client-*/
将与其他googleapiclient
python库一起包含在已构建应用程序的目录中,并且错误应消失.
Now when you fbs freeze
and subsequently fbs installer
your app, the google_api_python_client-*/
will be included in the built app's directory alongside other googleapiclient
python libraries, and the error should go away.
如果您的包装解决方案没有上述类似的挂钩,则:
If your packaging solution does not have similar hooks as above, then:
- 构建您的应用
- 将
google_api_python_client-*/
文件夹从<pythonInstallLocation>/lib/site-packages/
手动复制到构建的应用程序的目录中(或您编译的python脚本尝试访问google-api-python-client
的任何地方.) - 尝试启动该应用
- Build your app
- Manually copy the
google_api_python_client-*/
folder from<pythonInstallLocation>/lib/site-packages/
into the built app's directory (or wherever your compiled python scripts are trying to accessgoogle-api-python-client
. - Try starting the app
python fbs 冻结 google-api-python-client
这篇关于找不到'google-api-python-client'分发,使用pyinstaller的应用程序需要该分发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!