ID 611407 - pxr.Usd module does not import into an external Python session when using nuke as a module

Follow

Problem summary
pxr.Usd module does not import into an external Python session when using nuke as a module
 
This is based on following the instructions in our documentation here: https://learn.foundry.com/nuke/content/comp_environment/script_editor/nuke_python_module.html
 
Customer reported version
nuke.16.0v4
 
Customer reported platform
windows10
 
Steps to reproduce
 
1) Install Python, the same version as Nuke uses
 
2) Open a Command Prompt, and run the following, replacing the paths as needed (instructions based of the documentation page):
 
 
set PATH=C:\Program Files\Nuke16.0v7set USG_SHIMLIB_PATH=C:\Program Files\Nuke16.0v7set USG_USD_LIB_PATH=C:\Program Files\Nuke16.0v7\FnUSD\libset USG_USD_PLUGIN_PATH=C:\Program Files\Nuke16.0v7\FnUSD\plugin\usdset PYTHONPATH=C:\Program Files\Nuke16.0v7\lib\site-packagesset USG_SHIMLIB_NAME=C:\Program Files\Nuke16.0v7\FnUsdShim.0.6.dll
 
3) From the same Command Prompt, launch Python:
 
"C:\Program Files\Python311\python.exe"
 
4) In the Python session, run the following:
 
import nukefrom pxr import UsdUsd.Stage.CreateInMemory()
 
Expected behaviour
For the pxr.Usd module to work
 
Actual behaviour
It errors saying:
 
Traceback (most recent call last):  File "<stdin>", line 1, in <module>pxr.Tf.ErrorException:        Error in 'pxrInternal_v0_24__pxrReserved__::`anonymous-namespace'::_GetPluginForType' at line 187 in file Y:\.cs\a54681\1\USD_src\pxr\usd\ar\resolver.cpp : 'Failed to find plugin for NukeOpResolver'
 
Workaround
You can set the PXR_PLUGINPATH_NAME environment variable:
 
set PXR_PLUGINPATH_NAME=C:\Program Files\Nuke16.0v7\FnUsdAbstraction\resources
 
You should be able to use the USG_PLUGINS_PATH environment variable, however that currently has an issue with Windows paths
 
Reproduced by support
This bug has been reproduced in:
Nuke 16.0v7 - Windows 11
Nuke 14.1v1 - Windows 11
 
Unable to reproduce bug in:
Nuke 14.0v8 - Windows 11
 
Earliest version tested
Nuke 14.0v8 - This feature did not exist before this version
 
 

    We're sorry to hear that

    Please tell us why