Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kivy app not created when importing bleak module #6816

Closed
dgatf opened this issue Apr 9, 2020 · 4 comments
Closed

Kivy app not created when importing bleak module #6816

dgatf opened this issue Apr 9, 2020 · 4 comments
Labels

Comments

@dgatf
Copy link

dgatf commented Apr 9, 2020

Software Versions

  • Python: 3.7.7
  • OS: Windows 10
  • Kivy: 1.11.1
  • Kivy installation method: python -m pip install kivy

Describe the bug
Kivy app is not created when importing bleak module
The issue is with Windows 10. There is no issue with Ubuntu 18.10 and python 3.6.9

Expected behavior
Show kivy app

To Reproduce
Execute code below

Code and Logs and screenshots

from bleak import BleakClient
from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        return Button(text='Hello!')

MyApp().run()

Commenting from bleak import BleakClient removes the error
Bleak module is working properly alone. I can discover, read and subscribe to ble devices

Error:


[INFO ] [Logger ] Record log in C:\Users\danie\.kivy\logs\kivy_20-04-08_67.txt
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\danie\AppData\Local\Programs\Python\Python37\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - TypeError: __import__() takes at least 1 argument (0 given)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
[CRITICAL] [App ] Unable to get a Window, abort.

Additional context

Other python modules:

appdirs==1.4.3
bleak==0.6.1
certifi==2020.4.5.1
chardet==3.0.4
distlib==0.3.0
docutils==0.16
filelock==3.0.12
idna==2.9
importlib-metadata==1.6.0
Kivy==1.11.1
kivy-deps.glew==0.2.0
kivy-deps.sdl2==0.2.0
Kivy-Garden==0.1.4
plyer==1.4.3
PyBluez==0.23
Pygments==2.6.1
pypiwin32==223
pythonnet==2.4.0
pywin32==227
requests==2.23.0
six==1.14.0
urllib3==1.25.8
virtualenv==20.0.16
zipp==3.1.0
@matham
Copy link
Member

matham commented May 13, 2020

BleakClient requires async and is not compatible with kivy by default. You need to run kivy under async or run bleak in a separate thread using asyncio.

@matham matham closed this as completed May 13, 2020
@matham matham added the support label May 13, 2020
@support
Copy link

support bot commented May 13, 2020

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project.

If you're having trouble installing Kivy, make sure to check out the installation docs for Windows, Linux and macOS.

Let us know if this comment was made in error, and we'll be happy to reopen the issue.

@dgatf
Copy link
Author

dgatf commented May 13, 2020

Why you close the issue? As I said the code is working under linux (ubuntu) but is not working under windows, so it can't be related to an issue in the code

I know kivy 1.11.1 is not compatible with asyncio as it blocks the thread, but it should not raise that error. Under linux kivy blocks the thread when run preventing bleak to run, but gets launched
Also I know that Kivy 2.0.0rc2 is compatible if run in async mode (App.async_run())

So to clarify what I have tested:

  1. Kivy 1.11 .1: kivy running in a different thread, as you can see here Error when using bleak with kivy hbldh/bleak#176. Which is exactly what you suggested. And again that code is not working under windows and working under linux

  2. Kivy 2.0.0rc2 using asyncio with async_run in the same thread. I can provide the code if interesed. The result is the same. I always get the same error under windows but ok under linux

@bardiabarabadi
Copy link

Hello @dgatf ,
I had the same issue (until a few moments ago) and I resolved it by moving the import line for bleak after All of the Kivy functions (Lable, Button, ... )

It is a bit nasty to have an import line in the middle of your but it is the only way that I could make it work so far. Let me know if you have already found another way.
Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants