我尝试在手机上部署的应用程序在台式PC上运行良好。我使用以下命令将其部署在手机上:
buildozer android debug deploy run
当我尝试在手机上运行应用程序时,它崩溃了。使用:
adb logcat | grep python
我遇到以下错误:
ModuleNotFoundError:没有名为“ reportlab”的模块
我通过编辑buildozer.spec
文件来“解决”:
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy,reportlab
但是,当我尝试再次部署应用程序时,我得到了:
[INFO]: Downloading reportlab
[INFO]: -> running mkdir -p /home/pawel/PycharmPr...(and 82 more)
[INFO]: -> directory context /home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/build-armeabi-v7a/packages/reportlab
[INFO]: -> running basename https://bitbucket.org/...(and 40 more)
[INFO]: -> running rm c088826211ca.tar.gz
[INFO]: -> running rm -f .mark-c088826211ca.tar.gz
[INFO]: Downloading reportlab from https://bitbucket.org/rptlab/reportlab/get/c088826211ca.tar.gz
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1260, in <module>
main()
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 709, in __init__
getattr(self, command)(args)
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 216, in build_dist_from_args
args, "ignore_setup_py", False
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 555, in build_recipes
recipe.download_if_necessary()
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 347, in download_if_necessary
self.download()
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 393, in download
self.download_file(self.versioned_url, filename)
File "/home/pawel/PycharmProjects/TwoScreens/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 208, in download_file
urlretrieve(url, target, report_hook)
File "/usr/lib/python3.6/urllib/request.py", line 1826, in retrieve
block = fp.read(bs)
File "/usr/lib/python3.6/tempfile.py", line 624, in func_wrapper
return func(*args, **kwargs)
ValueError: read of closed file
我的理解是buidozer
正在尝试下载reportlab
,但失败了。我正在考虑手动下载reportlab
并将其放置在适当的文件夹中。无论如何,我不知道该怎么做。我也不确定是否能解决我的问题。任何帮助/提示将不胜感激。
答案 0 :(得分:0)
如果您仍然遇到此问题,那么我也有同样的问题,不幸的是,我仍然没有找到更好的方法来这样做,所以最后,我只是这样做了:
reportlab
的位置。就我而言,这是:~/home/samdev/repo/venv/myproject/lib/python3.7/site-packages
。reportlab
和reportlab.libs
复制到您的 root 项目文件夹中,然后reportlab
作为dep移至buildozer.spec
requirements
中。现在它应该没问题了