[Maya]Python IOError with Output Window disabled



Howdy folks. I’m having an issue in Maya whenever I try to do a simple print command. I’ve disabled my Maya Output Window because it literally serves no purpose for me and is quite annoying. However, now I cannot seem to do even a simple print command, else I get

# Error: IOError: file <maya console> line 1: 9 #

(this happens with both the print command and sys.stdout.write() )I know for a fact it’s due to the output window being disabled because as soon as I remove the environment variable in Windows the error goes away and I can print just fine. I could theoretically use

mel.eval(' print "foo" ')

But I think we can all agree that that’s clunky and not fun. Is there a way to bypass this? I really don’t want to have to enable the output window just to do a simple print command. And not being able to print makes troubleshooting quite difficult. Open to any and all input. Thank you.


Could you list the steps you did to remove the output window? What version as Maya as well?

I created a user environment variable MAYA_NO_CONSOLE_WINDOW=1 and it seems to be working fine in Maya2017.


Yeah I have the exact same environment variable. Perhaps the difference is I have 2016 (I’m weird and I like having even numbers for my Maya version).


It looks like if any exception is thrown from Python during startup AND the console window is being hidden (eg using MAYA_NO_CONSOLE_WINDOW) then any future calls to print from Python will result in:

Error: IOError: file

If the console window is visible on startup then this problem does not occur. Instead you get a nice callstack telling you where the issue is. Printing from mel works just fine regardless. You can fix the problem and restore printing by either showing the console window OR fixing whatever bug in your code is throwing the exception during startup.