Skip to content

Selecting mayapy.exe as a Python interpreter has broken since v2023.2.0 #20793

Closed

Description

Type: Bug

Behaviour

My guess: since v2023.2.0, Python extension tests interpreter(running interpreterInfo.py) with -I switch, which crashes mayapy.exe. As a result, Python extension decides mayapy.exe is an invalid interpreter.

Expected vs. Actual

Expected (e.g., in v2022.20.2):

LSP Notebooks experiment is disabled -- Jupyter disabled or not installed
LSP Notebooks interactive window support is disabled -- not in LSP Notebooks experiment
> "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" ~\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\interpreterInfo.py
Python interpreter path: C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe
Starting Pylance language server.
[ERROR 2023-2-3 19:32:31.74]: Active interpreter type is detected as Unknown {"id":"C:\\PROGRAM FILES\\AUTODESK\\MAYA2022\\BIN\\MAYAPY.EXE","sysPrefix":"C:\\Program Files\\Autodesk\\Maya2022\\Python37","envType":"Unknown","envName":"","envPath":"","path":"C:\\Program Files\\Autodesk\\Maya2022\\bin\\mayapy.exe","architecture":3,"sysVersion":"3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]","version":{"raw":"3.7.7","major":3,"minor":7,"patch":7,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.7.7 64-bit","detailedDisplayName":"Python 3.7.7 64-bit"}

Actual (since v2023.2.0):

LSP Notebooks experiment is disabled -- Jupyter disabled or not installed
LSP Notebooks interactive window support is disabled -- not in LSP Notebooks experiment
> "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
[ERROR 2023-2-3 19:42:6.606]: [Error: Command failed: "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000d80 (most recent call first):

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  killed: false,
  code: 3221226505,
  signal: null,
  cmd: '"C:\\Program Files\\Autodesk\\Maya2022\\bin\\mayapy.exe" -I c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\interpreterInfo.py'
}
> "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
[ERROR 2023-2-3 19:42:8.963]: [Error: Command failed: "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00004554 (most recent call first):

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  killed: false,
  code: 3221226505,
  signal: null,
  cmd: '"C:\\Program Files\\Autodesk\\Maya2022\\bin\\mayapy.exe" -I c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\interpreterInfo.py'
}

Indeed, mayapy.exe does not support -I switch at all. If you run mayapy.exe -I then the process will be crashed like this:

C:\Program Files\Autodesk\Maya2022\bin>mayapy -I
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000927c (most recent call first):

C:\Program Files\Autodesk\Maya2022\bin>mayapy -I -v
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'zipimport' # <class '_frozen_importlib.BuiltinImporter'>
# installed zipimport hook
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
import 'nt' # <class '_frozen_importlib.BuiltinImporter'>
import _thread # previously loaded ('_thread')
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import _weakref # previously loaded ('_weakref')
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import 'winreg' # <class '_frozen_importlib.BuiltinImporter'>
Fatal Python error: initfsencoding: unable to load the file system codec
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'encodings'

Note that mayapy.exe is the Autodesk customized version of python interpreter, which is heavily used in VFX industries, and may have quirky behaviors compared to the official CPython.

Steps to reproduce:

  1. I'm currently using Autodesk Maya 2022.4.
  2. Install Python extension v2023.2.0 or above with compatible VSCode version.
  3. Select C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe as a Python interpreter.
  4. Following notification will be displayed: "An Invalid Python interpreter is selected, please try changing it to enable features such as IntelliSense, linting, and debugging."

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda):
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

LSP Notebooks experiment is disabled -- Jupyter disabled or not installed
LSP Notebooks interactive window support is disabled -- not in LSP Notebooks experiment
> "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
[ERROR 2023-2-3 19:42:6.606]: [Error: Command failed: "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000d80 (most recent call first):

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  killed: false,
  code: 3221226505,
  signal: null,
  cmd: '"C:\\Program Files\\Autodesk\\Maya2022\\bin\\mayapy.exe" -I c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\interpreterInfo.py'
}
> "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
[ERROR 2023-2-3 19:42:8.963]: [Error: Command failed: "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" -I c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\get_output_via_markers.py c:\Users\swchung\.vscode\extensions\ms-python.python-2023.2.0\pythonFiles\interpreterInfo.py
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00004554 (most recent call first):

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  killed: false,
  code: 3221226505,
  signal: null,
  cmd: '"C:\\Program Files\\Autodesk\\Maya2022\\bin\\mayapy.exe" -I c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\get_output_via_markers.py c:\\Users\\swchung\\.vscode\\extensions\\ms-python.python-2023.2.0\\pythonFiles\\interpreterInfo.py'
}
**truncated after this line**

User Settings


languageServer: "Pylance"

formatting
• provider: "black"

Extension version: 2023.2.0
VS Code version: Code 1.75.1 (441438abd1ac652551dbe4d408dfcec8a499b8bf, 2023-02-08T21:32:34.589Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz (8 x 3000)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 63.93GB (39.28GB free)
Process Argv --crash-reporter-id 793b656b-3d9d-4200-bb92-a667409a2ae2
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
azure-dev_surveyone:30548225
vscccc:30610679
pyindex848:30662994
nodejswelcome1cf:30587006
3biah626:30602489
pyind779:30671433
f6dab269:30613381
pythonsymbol12:30671437
pythonb192:30669360
pythonms35cf:30676801

Activity

  1. karrtikr commented on Mar 3, 2023

    @karrtikr

    What is the Python version of this mayapy.exe? Note if it's Python 2 we do not support it anymore. Try running the following:

    "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" --version
    
  2. geesecross commented on Mar 4, 2023

    @geesecross
    Author

    What is the Python version of this mayapy.exe? Note if it's Python 2 we do not support it anymore. Try running the following:

    "C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe" --version
    

    Since Maya 2022, Autodesk starts to support Python 3 interpreter as a default (of course, there is a compatibility mode, which uses Python 2).

    And I'm running Python v3.7.7 64bit of mayapy.exe. In the log of expected result:

    [ERROR 2023-2-3 19:32:31.74]: Active interpreter type is detected as Unknown ... "sysVersion":"3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]", ...
    
  3. added
    regressionBug didn't exist in a previous release
    needs PRReady to be worked on
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Mar 6, 2023
  4. karrtikr commented on Mar 6, 2023

    @karrtikr

    Fix should be out in the pre-release version of the extension in a day, use the following to try it out:

    image

  5. geesecross commented on Mar 14, 2023

    @geesecross
    Author

    Fix should be out in the pre-release version of the extension in a day, use the following to try it out:

    image

    I confirmed now it works as expected. Thank you!

    Experiment 'pythonPromptNewToolsExt' is active
    LSP Notebooks experiment is disabled -- Jupyter disabled or not installed
    LSP Notebooks interactive window support is disabled -- not in LSP Notebooks experiment
    Python interpreter path: C:\Program Files\Autodesk\Maya2022\bin\mayapy.exe
    Starting Pylance language server.
    [ERROR 2023-2-14 10:58:39.27]: Active interpreter type is detected as Unknown {"id":"C:\\PROGRAM FILES\\AUTODESK\\MAYA2022\\BIN\\MAYAPY.EXE","sysPrefix":"C:\\Program Files\\Autodesk\\Maya2022\\Python37","envType":"Unknown","envName":"","envPath":"","path":"C:\\Program Files\\Autodesk\\Maya2022\\bin\\mayapy.exe","architecture":3,"sysVersion":"3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]","version":{"raw":"3.7.7","major":3,"minor":7,"patch":7,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.7.7 64-bit","detailedDisplayName":"Python 3.7.7 64-bit"}
    
  6. locked as resolved and limited conversation to collaborators on Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsauthor-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugregressionBug didn't exist in a previous releaseverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions