ID 494880 - Importing the nuke Python module results in an error on Windows

Follow

Problem summary
Importing the nuke Python module results in an error on Windows.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Nuke13.0v1\lib\site-packages\nuke.py", line 7, in <module>
    import _nuke
ImportError: DLL load failed: The specified module could not be found.
This happens with both third party Python interpreters, as well as Nuke's native Python interpreter.

Customer reported version
Nuke 13.0v5

Customer reported platform
Windows 10

Steps to reproduce

1) Open Command Prompt 

2) Run the following command:
"C:\Program Files\Nuke13.0v1\python.exe"

3) Try to import the nuke module, with the following command:
import nuke

Alternative steps to reproduce

1) Download and install Python 3.

2) Create a file named usrlocal.pth in the site-packages folder of your Python 3 install, for example:
C:\Users\[username]\AppData\Local\Programs\Python\Python37\Lib\site-packages\usrlocal.pth


3) Edit the file in a text editor and add the following line: 
C:\Program Files\Nuke13.0v5\Lib\site-packages

4) Save the usrlocal.pth file.

5) Run the Python 3 interpreter in Command Prompt, for example:
C:\Users\[username]\AppData\Local\Programs\Python\Python37\python.exe

6) Try to import the nuke module, with the following command:
import nuke

Expected behaviour
Nuke's native Python interpreter should be able to import the nuke module.
The steps in the Nuke as a Python Module section of the documentation should also allow you to import the nuke module into third party Python interpreters.

Actual behaviour
Importing the nuke Python module results in an error on Windows.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Nuke13.0v1\lib\site-packages\nuke.py", line 7, in <module>
    import _nuke
ImportError: DLL load failed: The specified module could not be found.
This happens with both third party Python interpreters, as well as Nuke's native Python interpreter.


Workaround
1) If you are trying to import the nuke module into a third party Python interpreter, you can add C:\Program Files\Nuke13.0v5 to your PATH environment variable.

2) If you are trying to use Nuke's native Python interpreter, you can first change your current directory in Command prompt to Nuke's install location. Then run the Python interpreter from this location:




Reproduced by support
This bug has been reproduced in:
Nuke 13.0v5 - Windows 10
Nuke 13.0v1 - Windows 10

Unable to reproduce bug in:
Nuke 13.0v5 - Linux CentOS 7
Nuke 12.2v9 - Windows 10

Earliest version tested
Nuke 12.2v9
- This issue doesn't appear in this version and has regressed

    We're sorry to hear that

    Please tell us why