简体   繁体   中英

Unable to print to PyCharm console with PyQt5

I'm building an app with PyQt5.

PyQt5 = 5.6.0

Python = 3.4.5

IDE = PyCharm Community Edition 2018 EAP

OS = Windows 10

The trouble I have is that any print()s I have in my code don't show up in the console when I run the app. This is making debugging very difficult as you can expect. For example,

module1.py (no PyQt/GUI code here): If I run this module separately then all the prints() are output to console

module2.py (all PyQt/GUI code is here): If I run this (it calls functions in module1.py) then the prints() do not output to console.

Someone suggested a solution here: https://forums.autodesk.com/t5/motionbuilder-forum/pyqt-pyside-event-handlers-don-t-print-to-console/td-p/7058029 but the module named pythonidelib doesn't seem to exist. I checked in Anaconda and other places but could not find it.

Does anyone know how to make print() work within a PyQt5 application or if there is an alternative.

try python logging, like this:

import logging

logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.DEBUG)  

logging.debug("print message!!!")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM