ID 543070 - Importing Nuke as module in an external Python install no longer works

Follow

Problem summary
Importing Nuke as module in external Python install no longer works
 
Python errors saying:
 
ImportError: DLL load failed while importing _nuke: The specified module could not be found.
 
Customer reported version
nuke.n/a
 
Customer reported platform
 
Steps to reproduce
 
1) Install Python 3.9.10: https://www.python.org/downloads/release/python-3910/

2) Open the Python install directory in a Command Prompt

3) Set the following environment variables in that Command Prompt :
 

set NUKE_INTERACTIVE=1set PATH=C:\Program Files\Nuke14.0v4\set PYTHONPATH=C:\Program Files\Nuke14.0v4\lib\site-packages\
 
4) Launch Python from that Command Prompt
 
5) Run the following command, it will fail:
 
import nuke
 
Expected behaviour
For the nuke module to be imported to an external version of Python, like it does on Linux:
[localpete@fwp782050 ~]$ cd /workspace/shared/Python-3.9.10/[localpete@fwp782050 Python-3.9.10]$ export NUKE_INTERACTIVE=1[localpete@fwp782050 Python-3.9.10]$ export PATH=/usr/local/Nuke14.0v4/:$PATH[localpete@fwp782050 Python-3.9.10]$ export PYTHONPATH=/usr/local/Nuke14.0v4/lib/python3.9/site-packages/[localpete@fwp782050 Python-3.9.10]$ ./pythonPython 3.9.10 (main, May 25 2023, 14:59:26) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import nukeLicence expires on: <DATE>
 
Actual behaviour
Importing nuke failed, it errored saying:
 
C:\Python39>set NUKE_INTERACTIVE=1C:\Python39>set PATH=C:\Program Files\Nuke14.0v4\C:\Python39>set PYTHONPATH=C:\Program Files\Nuke14.0v4\lib\site-packages\C:\Python39>python.exePython 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import nukeTraceback (most recent call last):  File "<stdin>", line 1, in <module>  File "C:\Program Files\Nuke14.0v4\lib\site-packages\nuke.py", line 7, in <module>    import _nukeImportError: DLL load failed while importing _nuke: The specified module could not be found.>>>
 
Workaround
Unknown.
 
Reproduced by support
This bug has been reproduced in:
Nuke 14.0v4/Python 3.9.10 - Windows 10
Nuke 14.0v1/Python 3.9.10 - Windows 10 - regression
 
Unable to reproduce bug in:
Nuke 14.0v4/Python 3.9.10 - CentOS 7.9
Nuke 13.2v7/Python 3.7.7 - Windows 10
*macOS not tested as importing nuke as a module is unsupported
 
Earliest version tested
Nuke 13.2v7 - This issue doesn't appear in this version and has regressed
 

    We're sorry to hear that

    Please tell us why