I am using Oracle VirtualBox running Ubuntu 16. I have been able to build apk files for a while until my latest build. My program will run and keep its functionality when run with python 2.7 on the same Virtual machine. When i install the .apk file on my Samsung S3 it shows the standard kivy loading screen then crashes after around 20 seconds. PLEASE HELP
I ran the latest build with verabose below is the log file.
https://drive.google.com/open?id=0B1XW1ekAndYiT2NrUTRNeHZhVGc
EDIT
After researching adb logcat i have been able to find this error. It occurs when "adb logcat" is run on a usb connected device.
I/python (29113): Traceback (most recent call last):
I/python (29113): File "/home/paul/Desktop/10/.buildozer/android/app/main.py", line 11, in <module>
I/python (29113): File "/home/paul/Desktop/10/.buildozer/android/app/_applibs/bs4/__init__.py", line 35, in <module>
I/python (29113): File "/home/paul/Desktop/10/.buildozer/android/app/_applibs/bs4/builder/__init__.py", line 315, in <module>
I/python (29113): ImportError: cannot import name _htmlparser
I/python (29113): Python for android ended.
EDIT
Line 11 in main.py is
from bs4 import BeautifulSoup as bs
I there something obvious im missing?
Turn USB Debuggin mode on in your device and connect your device to your PC and then run adb logcat. Run the application on your device and see what is going on in your application and what is the reason of crashing. you could also show us the the adb logcat result if you couldn't figure out the reason.
Related
Last 2 months ago, I was able to make my app work by building it in Google Collab and with the necessary buildozer file.
I am planning to build the app again because of minor changes, however upon launching the app, the app crashes. I used adb logcat to check the error and upon checking it, it generates this error:
02-15 22:46:41.308 9769 14717 I python : Traceback (most recent call last):
02-15 22:46:41.308 9769 14717 I python : File "/content/.buildozer/android/app/main.py", line 1, in <module>
02-15 22:46:41.308 9769 14717 I python : File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/ltlann/arm64-v8a/kivymd/__init__.py", line 34, in <module>
02-15 22:46:41.309 9769 14717 I python : File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/ltlann/arm64-v8a/kivy/__init__.py", line 130, in require
02-15 22:46:41.309 9769 14717 I python : Exception: The version of Kivy installed on this system is too old. (You have 2.1.0, but the application requires 2.2.0)
02-15 22:46:41.309 9769 14717 I python : Python for android ended.
Upon checking, it states that the first statement causes the error. However, the first statement is:
from kivymd.app import MDApp
For my app to work, I can only stick with Kivy 2.1.0, because whenever I use other versions of kivy, the camera feature of the application doesn't work. Moreover, I usually include this link: https://github.com/kivymd/KivyMD/archive/master.zip within the buildozer file, specifically for the app requirement.
Is there a way I can bypass this by changing the requirement or removing it if necessary?
Problem
My application works well when in python-only and on my machine. I am attempting to deploy to a machine which has lesser privileges.
The basic script that I am attempting to run at the moment:
import logging
import os
os.environ['PYUSB_DEBUG'] = 'debug'
os.environ['PYUSB_LOG_FILENAME'] = 'C:\\path\to\log.txt'
logging.basicConfig(level=logging.DEBUG)
import usb.core
import usb.util
devices = [d for d in usb.core.find(find_all=True,
idVendor=0x0683,
idProduct=0x2008
)]
[print(d) for d in devices]
device = devices[0]
device.set_configuration()
The imports are a bit out of whack in this example file because the os.environ variable must be set before usb import or the logging won't be set up properly to get my log.txt from the usb module.
From Python
When I execute the above script on my machine, this is the resulting log.txt:
2022-05-13 06:50:02,760 DEBUG:usb.backend.libusb1:_LibUSB.__init__(<WinDLL 'C:\WINDOWS\system32\libusb-1.0.dll', handle 7ff8476e0000 at 0x20a622c18b0>)
2022-05-13 06:50:02,760 DEBUG:usb.backend.libusb1:_LibUSB.__init__(<WinDLL 'C:\WINDOWS\system32\libusb-1.0.dll', handle 7ff8476e0000 at 0x20a622c18b0>)
2022-05-13 06:50:02,766 INFO:usb.core:find(): using backend "usb.backend.libusb1"
2022-05-13 06:50:02,766 INFO:usb.core:find(): using backend "usb.backend.libusb1"
2022-05-13 06:50:02,767 DEBUG:usb.backend.libusb1:_LibUSB.enumerate_devices()
...
...(more logs past this point, but you can see that the core found the backend)
From pyinstaller executable
I am bundling using pyinstaller. I normally like to use --onefile, but I always verify functionality without --onefile. I am only doing the most basic build: pyinstaller --noconfirm path/to/script.py
The console error:
Traceback (most recent call last):
File "usb\backend\libusb0.py", line 738, in get_backend
File "Lib\site-packages\_pyinstaller_hooks_contrib\hooks\rthooks\pyi_rth_usb.py", line 57, in _load_libraryOSError: USB library could not be found
Traceback (most recent call last):
File "backend_test.py", line 15, in <module>
File "usb\core.py", line 1309, in find
usb.core.NoBackendError: No backend available
[9344] Failed to execute script backend_test
Note that the USB library failed to find a backend.
The fail log.txt when attempted to run the executable:
Traceback (most recent call last):
File "usb\backend\libusb0.py", line 738, in get_backend
File "Lib\site-packages\_pyinstaller_hooks_contrib\hooks\rthooks\pyi_rth_usb.py", line 57, in _load_library
OSError: USB library could not be found
2022-05-13 06:20:59,838 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend
Traceback (most recent call last):
File "usb\backend\libusb1.py", line 961, in get_backend
File "Lib\site-packages\_pyinstaller_hooks_contrib\hooks\rthooks\pyi_rth_usb.py", line 57, in _load_library
OSError: USB library could not be found
2022-05-13 06:20:59,840 ERROR:usb.backend.openusb:Error loading OpenUSB backend
Traceback (most recent call last):
File "usb\backend\openusb.py", line 745, in get_backend
File "Lib\site-packages\_pyinstaller_hooks_contrib\hooks\rthooks\pyi_rth_usb.py", line 57, in _load_library
OSError: USB library could not be found
2022-05-13 06:20:59,842 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend
Traceback (most recent call last):
File "usb\backend\libusb0.py", line 738, in get_backend
File "Lib\site-packages\_pyinstaller_hooks_contrib\hooks\rthooks\pyi_rth_usb.py", line 57, in _load_library
OSError: USB library could not be found
At the moment, I can tell that the failure is occurring in a pyinstaller hook. I don't understand precisely how this works, so the clue may be found somewhere in there.
Background & Research
Versioning
libusb==1.0.24b3
pyinstaller==4.3
pyinstaller-hooks-contrib==2022.4
pyusb==1.2.1
... (there is more, but I suspect that these are the critical-to-function packages)
libusb
Not sure why this installed the beta version. Interesting, but doesn't appear to be the smoking gun.
pyinstaller
Note that pyinstaller==4.3 is a bit out of date. This is a result of my overambitious IT department's antivirus. It doesn't appear to want to allow more recent versions of pyinstaller to build executables.
pyinstaller-hooks-contrib
This is a repository which contains several pyinstaller hooks. I know that these are "critical to function" for lots of modules, but I don't really know how this works. It is possible, even likely given that this is where something is failing, that my problem lies within this library OR with this library's interaction with the version of pyinstaller that I'm using. Version 2022.4 is the version that is installed when I python -m pip install pyinstaller.
pyusb
Current version.
Other Attempts Thus Far
I have been up and down the web and have spent a particularly long time with the SO question Pyusb on windows - no backend available. Many of the below attempts were based on that SO question, but there have been other sources as well.
There are more attempts than just these, but I have been at it long enough that I don't remember them all!
Bundling libusb-1.0.dll into Executable
It is possible to bundle dll files directly with the pyinstaller-created script using the datas directive. This was my first attempt and it worked... on my machine. As soon as I deployed, the script failed with a PermissionError. I suspect that "untrusted" dll's aren't allowed to be utilized on the target machine. My login on my machine has elevated privileges, explaining why it may have worked in my environment.
Installing libusb-win32-devel-filter.exe.
Simply didn't work.
Including C:\\Windows\\System32 on PATH
I verified that the PATH variable contained C:\\Windows\\System32, which I also verified contains the proper dll file.
Specify backend
When I modify the script to specify the backend:
...
import usb.backend.libusb1 as libusb1
be = libusb1.get_backend(find_library=lambda x: "C:\\WINDOWS\\system32\\libusb-1.0.dll")
devices = [d for d in usb.core.find(find_all=True,
idVendor=0x0683,
idProduct=0x2008,
backend=be)]
...
There is no change in behavior. I do see in the log when running in python (not pyinstaller) that the backend is immediately found:
2022-05-13 07:22:12 USBN1LPGDKWXD3 usb.backend.libusb1[6880] DEBUG _LibUSB.__init__(<WinDLL 'C:\Windows\System32\libusb-1.0.dll', handle 7ff840bd0000 at 0x190eadbe820>)
2022-05-13 07:22:12 USBN1LPGDKWXD3 usb.backend.libusb1[6880] DEBUG _LibUSB.enumerate_devices()
2022-05-13 07:22:12 USBN1LPGDKWXD3 usb.backend.libusb1[6880] DEBUG _LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x00000190EAE58EB0>)
2022-05-13 07:22:12 USBN1LPGDKWXD3 usb.backend.libusb1[6880] DEBUG _LibUSB.get_device_descriptor(<usb.backend.libusb1._Device object at 0x00000190EAE58F40>)
...
Install libusb
No change.
Modify pyinstaller and pyinstaller-hooks-contrib versions
Tried pyinstaller==4.10 and python-hooks-contrib==2022.3, which appear to be "compatible" releases.
I would like to try to build the pyinstaller script by excluding the pyusb from pyinstaller-hooks-contrib, but I'm not sure how to do this.
Other Clues....
While looking in pyinstaller-hooks-contrib, I'm seeing the way to access DLL files is through ctypes.WinDLL.
import ctypes
print('ctypes.WinDLL', ctypes.WinDLL('libusb-1.0.dll'))
Result when running from python: <WinDLL 'libusb-1.0.dll', handle 7ff831cc0000 at 0x21076e9adf0>
Result when running from pyinstaller: ctypes.WinDLL <PyInstallerWinDLL 'libusb-1.0.dll', handle 7ff83d400000 at 0x201a9f39fa0>
I'm still not sure why this works the way that it does, but my initial instincts were correct when I had tried to include libusb-1.0.dll in the pyinstaller package. Unfortunately, there is apparently an issue with the windows implementation of the libusb-1.0.dll (I'm not making that assertion, I'm quoting another SO answer).
The answer, for me, was to add libusb0.dll to my pyinstaller build directory instead of the more recent libusb-1.0.dll:
a = Analysis(['examples\\backend_test.py'],
pathex=[],
binaries=[],
datas=[('C:\\Windows\\System32\\libusb0.dll', '.'),],
hiddenimports=[],
...])
I can't believe that it was this simple in my case, but there it is...
I can find many questions related to the module PIL not found, with solutions. I tried many that I thought were applicable to me. BUt I still have no luck :(
My problem is this:
I have a project that shows current NAV of a portfolio using a KivyMD MDDataTable. The portfolio information is read from a PDF file using using MDFileManager and using tabula and panda, the file is parsed. Then market data is obtained from relevant markets and NAV is calculated. This then is displayed using MDDatatable. I am using python 3.8, kivy 2.0.0rc4, and kivyMD 0.104.1. I can run this from the IDE and works beautifully. The problem is when running on my android phone
I use buildozer to create the apk file. The app starts, the splash screen is displayed and then it shuts off. logcat output shows this error which I believe is the reason as the first screen in the app uses filemanager( MDFileManager instance)
> 2020-10-24 13:13:54.517 24104-24183/? I/python: Traceback (most recent call last):
> 2020-10-24 13:13:54.518 24104-24183/? I/python: File "/home/tksrajan/dev/mark2market/.buildozer/android/app/main.py", line
> 8, in <module>
> 2020-10-24 13:13:54.519 24104-24183/? I/python: File "/home/tksrajan/dev/mark2market/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/mark2market/kivymd/uix/filemanager.py",
> line 119, in <module>
> 2020-10-24 13:13:54.520 24104-24183/? I/python: ModuleNotFoundError: No module named 'PIL'
> 2020-10-24 13:13:54.520 24104-24183/? I/python: Python for android ended.
Thanks for any help in advance.
This problem is in the latest released version of kivyMD 0.104.1. The import of PIL in filemanager.py is superfluous and does nothing. You can fork the repo, remove the import and and use the modified repo. This solves the problem. The master branch of kivyMD has already removed this import. So next release will fix the problem permanently
I want to debug with Pycharm on windows 10. So I reference the youtube video.
How to debug Odoo using Pycharm in Window 10
https://www.youtube.com/watch?v=aCXlh4Z2mbQ
I copy the server directory form odoo 11 installed directory. And then use Pycharm to open.
I also install Package reuirements and Visual C++ 14.0(in odoo 11 vcredist directory).
I install win-psycopg for python 3.5, because it does not support Python 3.6.1.
My Pycharm configuration setting as below:
Script path = odoo-bin
Parameters = -w openpg -r openpgpwd --addons-path=addons
Working directory = D:\tmp\server
When I run the project , Pycharm displays error messages as below:
Does somebody know how to solve it?
D:\Python36\python.exe odoo-bin -w openpg -r openpgpwd --addons-path=addons
Traceback (most recent call last):
File "odoo-bin", line 5, in
import odoo
File "D:\tmp\server\odoo__init__.py", line 84, in
from . import modules
File "D:\tmp\server\odoo\modules__init__.py", line 8, in
from . import db, graph, loading, migration, module, registry
File "D:\tmp\server\odoo\modules\graph.py", line 10, in
import odoo.tools as tools
File "D:\tmp\server\odoo\tools__init__.py", line 10, in
from .convert import *
File "D:\tmp\server\odoo\tools\convert.py", line 22, in
from .yaml_import import convert_yaml_import
File "D:\tmp\server\odoo\tools\yaml_import.py", line 23, in
from .safe_eval import safe_eval
File "D:\tmp\server\odoo\tools\safe_eval.py", line 21, in
from psycopg2 import OperationalError
File "D:\Python36\lib\site-packages\psycopg2-2.6.2-py3.6-win-amd64.egg\psycopg2__init__.py", line 50, in
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ModuleNotFoundError: No module named 'psycopg2._psycopg'
Process finished with exit code 1
The error:
ModuleNotFoundError: No module named 'psycopg2._psycopg'
it's because you lose dependencies for odoo server, in this case psycopg2 just excecute:
pip install psycopg2-binary
I hope this answer can be helpfull for you or anyone else.
I have a kivy app, which runs on my linux desktop.
I can also build it with buildozer and run the app on my android phone.
I include a sync with google-drive through the pydrive modul -> works on linux.
I added PyDrive to the requirements in my buildozer.spec file but when i run my app on android ,I get the following error on my phone via adb:
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/main.py", line 23, in <module>
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/drivesync.py", line 1, in <module>
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/_applibs/pydrive/drive.py", line 2, in <module>
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/_applibs/pydrive/files.py", line 4, in <module>
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/_applibs/apiclient/__init__.py", line 17, in <module>
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/_applibs/googleapiclient/discovery.py", line 50, in <module>
I/python (16976): File "/home/taper/Dokumente/py-spielwiese/myapp/.buildozer/android/app/_applibs/httplib2/__init__.py", line 95, in <module>
I/python (16976): ImportError: No module named iri2uri
Some modules are blacklisted. You can check in .buildozer/android/platform/python-for-android/src/blacklist.txt if iri2uri is.
Also you can try to add iri2uri to you buildozer.spec requirements
I have a very similar problem. I'm trying to send an email using the GMail API with OAuth2 authentication. It works on my PC, but it crashes immediately on my smartphone.
I tried to include iri2uri in the buildozer.spec, but buildozer couldn't create the APK.
I'm not sure if it helps, but in this thread someone suggest to use an Android flow instead of a web flow.
https://groups.google.com/forum/#!starred/kivy-users/3K9y1X0QcHM