Skip to main content

Unable to import 'ZOSAPI-NetHelper'

  • November 27, 2020
  • 2 replies
  • 258 views

I am running a sample file for a Python Standalone Application, 'PythonStandalone_01_new_file_and_quickfocus.py' and the developer environment (Visual Studio Code) flags up 2 problems:

Unable to import 'ZOSAPI-NetHelper'

Unable to import 'ZOSAPI'

The relevant lines of code in the sample file are:

        aKey = winreg.OpenKey(winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER), r'Software\Zemax', 0, winreg.KEY_READ)
        zemaxData = winreg.QueryValueEx(aKey, 'ZemaxRoot')
        NetHelper = os.path.join(os.sep, zemaxData[0], r'ZOS-API\Libraries\ZOSAPI_NetHelper.dll')
        winreg.CloseKey(aKey)
        clr.AddReference(NetHelper)
        import ZOSAPI_NetHelper

        import ZOSAPI

I can see that the dll files are present at the filepath location. 

The code does run and generates a zemax file. Do I need to worry about these problems?

Forum|alt.badge.img+2

Hello Stephen,

It seems like the connection works even with an error. Have you tried to close Visual Studio and reopened it again? For C++, I know that you have to build the solution once, close Visual Studio and reopen it for it to work properly. I am wondering if it can be the same kind of issue.

Sandrine


Forum|alt.badge.img

Hi Webster,

As i have test, the python code will work correctly if you run it in IDLE. What’s difference between VS code and IDLE? It’s amazing~:

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings