Skip to content Skip to sidebar Skip to footer

Python Kivy Is Printing Numbers While Importing It

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.

Solution 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

Post a Comment for "Python Kivy Is Printing Numbers While Importing It"