'Python.Runtime.PythonException: 'NoneType' object has no attribute 'write'
trying out a few things with python.NET, its working ok in debug or release, but throw exceptions when I lauch through .exe, here is the stack trace:
Python.Runtime.PythonException: 'NoneType' object has no attribute 'write'
at Python.Runtime.PythonException.ThrowLastAsClrException()
at Python.Runtime.PyObject.Invoke(PyTuple args, PyDict kw)
at Python.Runtime.PyObject.TryInvoke(InvokeBinder binder, Object[] args, Object& result)
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
From those issues, i understood that it is caused by python trying to log things when there is not console object to log to, and it seems from the git issue that calling
Keras.Keras.DisablePySysConsoleLog = true; at start,or onload
would be enough to prevent the logs, but i can't find the property in tensorflow.keras(i am not using the keras module directly) and I can't find it in the documentation, what do they exactly mean by that?
edit: Ok nevermind, just saw that the issue is about Keras.net, i wouldnt mind a solution for PythonNet though
edit2: It turns out one of the python module i use was calling stderr, which normally outputs to visual studio console, but since it is launched from exe there is no console to log to and the code would except, redirected the stderr stream to a relative file and it fixed the issue
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
