Skip to main content
Solved

Unable to connect Python (Spyder) to Zemax

  • Dec 23, 2022 9:12 AM UTC
  • 6 replies
  • 505 views

Hi , 

I am currently trying to use python (Spyder) to connect with Zemax. 

But I am getting the errors below (shown in the picture below) . I can’t find any solution. 
I tried to use another python version - 3.7.0 , but still same error. Both standalone application and interactive extension result in same error messages. 

Appreciate if anyone could give me some guidance. Thank you 

 

 

 

 

 

Best answer by Sandrine Auriol

Hi @Eric.Aw 

I had a similar problem and this post helped me: https://stackoverflow.com/questions/47913079/python-attributeerror-module-object-has-no-attribute-addreference

View original

6 replies

David.Nguyen
Luminary
Forum|alt.badge.img+3

Hi Eric,

 

I’m assuming you are generating the tepmlate code from the latest OpticStudio version: Programming > Python > Standalone Application / Interactive Extension.

Can you tell us your version of Pythonnet as well? There have been issues with Pythonnet 3.0.0 and Zemax recommend using Pythonnet 2.5.2 for the moment:

Take care,

 

David


  • Author
  • Monochrome
  • Dec 28, 2022 2:11 AM UTC

Hi David, 

 

Thank you for the advice. Yes, I am generating the template from that method. 


I have uninstall Pythonnet 3.0.0 and installed 2.5.2. However, the error continue to occur. 

 

Is there any other method/way I could try ? 


Ethan
En-Lightened
Forum|alt.badge.img+2
  • En-Lightened
  • Jan 13, 2023 4:11 AM UTC

Hi @Eric.Aw,

I’m wondering if you are missing a required package for Python. In order for clr to work properly, you need to install the Pythonnet library. It could be corrupted as well, so try uninstalling/reinstalling it if you’ve already added it to your Python installation.

There are also some good suggestions here in this Community article: ZOSAPI_NetHelper cannot be added | Zemax Community.

Best,
Ethan 


Forum|alt.badge.img+2

  • Author
  • Monochrome
  • Jan 31, 2023 1:30 AM UTC

Hi @Ethan , @Sandrine Auriol 

Thank you very much for the advice. 
At the end , I uninstall everything (python and spyder) and install everything again. Then follow some of the guide above and it works. 

 

Thank you 


Ethan
En-Lightened
Forum|alt.badge.img+2
  • En-Lightened
  • Jan 31, 2023 5:32 PM UTC

Hi @Eric.Aw,

I’m glad to hear you got it working! Thanks for updating the Community with your findings.

Best,
Ethan