Skip to main content
Solved

Unable to connect Python (Spyder) to Zemax

  • December 23, 2022
  • 6 replies
  • 370 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
Did this topic help you find an answer to your question?

6 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1089 replies
  • December 24, 2022

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
  • 3 replies
  • December 28, 2022

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
  • 107 replies
  • January 13, 2023

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
  • 3 replies
  • January 31, 2023

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
  • 107 replies
  • January 31, 2023

Hi @Eric.Aw,

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

Best,
Ethan

 


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