Python - No handlers could be found for logger "OpenGL.error"
Asked Answered
P

3

79

Okay, what is it, and why does it occur on Win2003 server, but not on WinXP.

It doesn't seem to affect my application at all, but I get this error message when I close the application. And it's annoying (as errors messages should be).

I am using pyOpenGl and wxPython to do the graphics stuff. Unfortunately, I'm a C# programmer that has taken over this Python app, and I had to learn Python to do it.

I can supply code and version numbers etc, but I'm still learning the technical stuff, so any help would be appreciated.

Python 2.5, wxPython and pyOpenGL

Polygynist answered 6/12, 2008 at 5:59 Comment(2)
I think the "no handlers could be found" is a canonical issue that occurs for not just Python's OpenGL library but many python libraries. Right now though when I google "python no handlers could be found for logger" I find this question seems to be the closest I to a canonical question/solution.Chasseur
In case someone came here looking for this https://mcmap.net/q/262945/-no-handlers-could-be-found-for-logger/1581226Curse
S
195

Looks like OpenGL is trying to report some error on Win2003, however you've not configured your system where to output logging info.

You can add the following to the beginning of your program and you'll see details of the error in stderr.

import logging
logging.basicConfig()

Checkout documentation on logging module to get more config info, conceptually it's similar to log4J.

Scree answered 6/12, 2008 at 17:18 Comment(1)
This was really helpful. I was able to get the error text out of my application, not to track down the issues.Polygynist
S
3

The proper way to get rid of this message is to configure NullHandler for the root level logger of your library (OpenGL).

Shithead answered 28/9, 2013 at 21:19 Comment(4)
I presume you were down-voted because ignoring log messages with the NullHandler is rarely the right thing to do. The reported message is often a sign that the logger was not configured at a point when it should have been configured already and you also are ignoring a potential issue with the component that was trying to log something. In some cases using the NullHandler might be the right thing to do, but rarely IMO.Smote
@MoisesSilva for a library NullHandler is a must. It doesn't turn off the logging - it just allows fine-grained control over it Think reset.cssShithead
You are right. In the context of this question however, the op have his own application that is using OpenGL, so it is best to configure the logger to print the error that OpenGL was trying to report. That lead him to fix the root cause of the problem.Smote
The link provides some interesting reading (blog post with associated official Python bug reports) that demonstrates common issues people have with the Python logging module.Chasseur
P
2

After adding the Logging above, I was able to see that the problem was caused by missing TConstants class, which I was excluding in the py2exe setup.py file.

After removing the "Tconstants" from the excluded list, I no longer had problems.

Polygynist answered 15/12, 2008 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.