Skip to main content

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?

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


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