What to do if the print command itself causes an error in Maya python

The following is a story that is relevant only to certain Maya versions of Windows. I've never encountered it on a Mac or a recent version of Maya.


{55B3F311-97DE-4B88-944A-B52411ACC23C}.png.jpg That's stupid! ??

If you encounter the mysterious phenomenon that the print command itself causes an error as described above, make sure that MAYA_NO_CONSOLE_WINDOW is not set in the system environment variable.

This is an environment variable that you set to hide the console window. https://support.borndigital.co.jp/hc/ja/articles/360002474194-Maya-%E3%81%AE-Output-Window-%E3%82%92%E9%9D%9E%E8%A1%A8%E7%A4%BA%E3%81%AB%E3%81%99%E3%82%8B

If MAYA_NO_CONSOLE_WINDOW is set, the print statement will not pass in some environments such as Maya 2017 Update 5 (although the exact target version is unknown). As far as I tried, it didn't work even if the set value was 0 instead of 1.

The situation where print does not pass seems to be when the stdout setting is incorrect, and by not displaying the console window, the allocation will be lost.

For the time being, you can fix it by executing the code below, but it seems better to remove the MAYA_NO_CONSOLE_WINDOW definition because something else may be wrong.

# https://stackoverflow.com/questions/43633433/maya-python-ioerror-errno-9-bad-file-descriptor
import maya.utils as utils
 sys.stdout = utils.Output()

It's unpleasant that problems occur only in a specific environment.


image.png FIXED!

Recommended Posts

What to do if the print command itself causes an error in Maya python
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if you run python in IntelliJ and end with an error
[python] What to do when an error occurs in send_keys of headless chrome
What to do if a Unicode Encode Error occurs in Sublime Text Python
What to do if you get an error when installing python with pyenv
What to do if a version error occurs in the selenium Chrome driver
What to do if PyInstaller3.5 gives an error in Python3.8 (TypeError: an integer is required (got type bytes))
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
In the python command python points to python3.8
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
What to do if the progress bar is not displayed in tqdm of python
What to do if Python does not switch from the System version in pyenv
What to do if you can't hit the arrow keys in the Python interactive console
What to do if you get Swagger-codegen in python and Import Error: No module named
What to do if you get an error when running "certbot renew" in CakePHP environment
[AWS] What to do when the ping command causes a "timeout"
What to do if you get a minus zero in Python
What to do if you can't use the trash in Lubuntu 18.04.
What to do when the value type is ambiguous in Python?
What to do if you get an error saying c compiler cannot create executables in configure
What to do if pip --user returns an error in a virtual environment created with pyenv
What to do if there is a decimal in python json .dumps
What to do if you can't use scikit grid search in Python
What to do if the yum command fails to set locale, defaulting to C
What to do if pyenv install does not proceed with an error
What to do if No Python documentation found for ... appears in pydoc
[Python] What to do when an error related to SSL authentication is returned
What to do if the server doesn't start with python manage.py runserver
What to do if an error occurs when importing numpy with VScode
What to do if you get an error when trying to load mnist
What to do if you get an error when installing Dlib (Ubuntu)
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do if pipreqs results in UnicodeDecodeError
What to do to get google spreadsheet in python
What to do if you get an error like'Qstring' has already been set to version 1 using mne python
What to do if you get angry with "Value Error: unknown local: UTF-8" in python manage.py syncdb
[Django] What to do if an Integrity Error occurs when registering data from the management site to the database
What to do if a symbolic link error occurs in import cv while trying to install OpenCV in Python
What to do if you get the error Target WSGI script'/var/www/xxx/xxx.wsgi' cannot be loaded as python module
What to do if an error occurs in TensorFlow RNN related import or RNN (LSTM) Cell (v 0.11r ~)
What to do if you get a "No versions found" error in pipenv
[Python] I want to know the variables in the function when an error occurs!
Let's Encrypt updated! What to do if the certbot renew command doesn't work
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if an SSL connection error (ssl.SSLError: [SSL: DH_KEY_TOO_SMALL]) occurs on Ubuntu 20.04
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
What to do if an error occurs when loading a python project created with poetry into VS Code
What to do if pip install fails in Xcode 5.1
How to get the variable name itself in python
What to do if a UnicodeDecodeError occurs in pip
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
What to do if you get the error RuntimeError: Python is not installed as a framework when trying to use matplitlib and pylab in Python 3.3
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if you get an "unknown service" error from your gRPC server
What to do if you get `No kernel for language python found` in Hydrogen
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do if Sort imports get stuck in VS Code's Python Extension (around 2020/09)
What to do if you get an Import Error when importing matplotlib with Jupyter