ID 154593 - Adding "import hiero" to the init.py or menu.py files in your .nuke directory prevents Nuke from running

Follow

Problem summary
Nuke 9.0v1 and later can use Hiero's python libraries for coding hiero-ic functions within Nuke/NukeStudio. You can use "import hiero" in the Script Editor to load these libraries.

However, if you try to define Hiero python functions within your init.py or menu.py in your .nuke directory, Nuke will fail to load. (See below error)

Customer reported version
NukeStudio 9.0v1
 
Customer reported platform
Windows 7
 
Steps to reproduce
 
1)  Create a text document
 
2)  add 'Import Hiero' to the document and save as a '.py' file
 
3)  Open NukeStudio in command prompt or terminal with your script, example below:
     ' "\PathToNuke\Nuke10.5v5\Nuke10.5.exe" -studio -i -t \pathToFile\testFile.py '
 
Result - Nuke will fail to load with the following error:

import hiero
File "C:\Program Files\Nuke9.0v3\pythonextensions\site-packages\hiero\__init__.py", line 2, in
import FnRedirect
File "C:\Program Files\Nuke9.0v3\pythonextensions\site-packages\hiero\FnRedirect.py", line 1, in
from _fnpython import *
ImportError: No module named _fnpython
 
Workaround
To add Hiero customisation to NukeStudio startup scripts, you need to add your Python script into the following directory:  ~/.nuke/Python/Startup (This is the Hiero file structure for python customisation.)  

As _fnpython is a private module which is created in the application code (similar to _nuke). The reason this doesn't work is that init.py is executed before Hiero's Python modules are properly initialised.

So currently the only option to startup Python files which need to call the hiero APIs is that they need to be placed in the location as above (~/.nuke/Python/Startup).
 
Reproduced by support
Nuke 10.5v5 - Windows 7 - Mac10.12 - CentOS6.9  
Nuke 10.5v1 - Windows 7 - Mac10.12 - CentOS6.9  
Nuke 10.0v4 - Windows 7 - Mac10.12 - CentOS6.9  
Nuke 10.0v1 - Windows 7 - Mac10.12 - CentOS6.9  
Nuke 9.0v9 - Windows 7 - Mac10.12 - CentOS6.9  
Nuke 9.0v1 - Windows 7 - Mac10.12 - CentOS6.9 - regression 
 
Hiero 1.8v2 - Windows 7 - unable to reproduce
 
Earliest Version tested
Hiero 1.8v2 - Windows 7
 
Expected Behaviour
Ability to use python queries in startup scripts before launching Nuke studio 
 
Actual Behaviour
NukeStudio releases an error 'ImportError: No module named _fnpython' because Python modules aren't initialized until after the init.py is executed.

    We're sorry to hear that

    Please tell us why