Python Kivy Is Printing numbers while importing it

浪尽此生 提交于 2019-12-11 06:34:58

问题


I just installed Kivy in my virtualenv

I installed it using pip install https://github.com/kivy/kivy/archive/master.zip

My dependencies

Python 2.7.10
Kivy==1.10.1.dev0
Cython==0.26.1
Kivy-Garden==0.1.4

When I tried to run it in my terminal using command from kivy.app import App

Its printing integers recursively I have attached screenshot below

Thanks in advance!!

I Have Raised A GIT ISSUE ALSO :- https://github.com/kivy/kivy/issues/5515


回答1:


I'll propose a workaround: it's to turn off printing from python during imports. It's lame but will fix in while they're fixing the forgotten print properly:

import sys

def write(x):
    pass
saved = sys.stdout.write
sys.stdout.write = write

from kivy.app import App  # works for any import that uses stdout to print stuff

sys.stdout.write = saved

just save sys.stdout.write, then override it with a method that does nothing, then import. Restore standard output after importing.

I've tested it with a custom module that prints stuff when imported, and it suppresses the prints. If it doesn't work, the same thing can be tried with sys.stderr.write




回答2:


Kivy has no support to python 2.7 so kindly update your python to 3x then reinstall kivy I guess it will work!!

Cheers



来源:https://stackoverflow.com/questions/47671606/python-kivy-is-printing-numbers-while-importing-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!