Maya Python # IOError: [Errno 9] Bad file descriptor //

I created a maya python toolchain for my team. All goes well, just on one machine i seem to have problems. I narrowed it down to the print command. Like this test library called “temp.py”:

import os
# from pymel.core import *

print "Hello"

after importing it with

import temp

produces this output (only on that one computer!):

// Error: 9
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# File "C:\maya_scripts\temp.py", line 4, in <module>
# print "Hello"
# IOError: [Errno 9] Bad file descriptor //

I’ve tried Maya Version 2016, 2016.5 and 2017. All the same result. Python 2.5 as standalone hasn’t got that problem. me that sounds like some kind of configuration problem, but then again it behaves the same over 3 different maya installations, so deleting the prefs didn’t help either. Any idea where to look?

have you tried any other file name than temp.py?

Yea, tried that, but it’s not that. The only sort of lead i got was this thread about “sys.stdout is not available when not running as a console session.”, but i wouldn’t know how i would test that in maya.

Another solution would be to eliminate all occurances of the print command in my code, but this is quite a radical solution for a single machine…

Okay, i got some more. Actually the problem goes much deeper. Turns out this already throws the same error:

import sys, os

sys.stdout.write("Hello\n")

In the maya script editor. On all 3 versions of maya.

See the StackOverflow question. I think somebody overwrote Maya’s default Output object.