问题
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