Issue starting Lumerical FDTD via Python API

johnrollinsonjohnrollinson Member Posts: 1


I am running into an issue where I can run FDTD simulations via the GUI, but I cannot run them via the Python API. If I try to run the following line:

fdtd = lumapi.FDTD(hide=False)

The execution will just hang indefinitely. If I kill the script, I get the following error output:

Traceback (most recent call last):

 File "/home/rhome/rollij2/lumerical/gf_grating_coupler/45spclo/", line 502, in <module>

  with lumapi.FDTD(hide=False) as fdtd:

 File "/opt/lumerical/v211/api/python/", line 1294, in __init__

  super(FDTD, self).__init__('fdtd', filename, key, hide, serverArgs, **kwargs)

 File "/opt/lumerical/v211/api/python/", line 1072, in __init__

  self.handle = open(product, key, hide, serverArgs)

 File "/opt/lumerical/v211/api/python/", line 231, in open

  h = iapi.appOpen(url, k)


Exception ignored in: <function Lumerical.__del__ at 0x7f84e04f6790>

Traceback (most recent call last):

 File "/opt/lumerical/v211/api/python/", line 1170, in __del__


AttributeError: 'FDTD' object has no attribute 'handle'

So it looks like it is getting stuck when it is trying to open an FDTD instance. This issue just started appearing today, seemingly out of nowhere. Any help in debugging or fixing the issue is greatly appreciated.


Best Answer


  • johnrollinsonjohnrollinson Posts: 6Member
    edited June 3

    Update: We updated our Lumerical installation and the issue is still persisting (previously we were using v2020 R2.4, I believe).

    Now, instead of getting stuck indefinitely, it is giving us an error (still at the same point in the code though):

    lumapi.LumApiError: 'appOpen error: \n Failed to start messaging, check licenses...'

    As far as I am aware, there have been no changes to our license. When we check the Ansys license manager log, we don't see any errors.

  • johnrollinsonjohnrollinson Posts: 6Member

    Another update: it seems like the issue only happens when I try to run Python scripts from a separate Python IDE. If I run the script from the Lumerical script file editor, this issue doesn't happen.

  • gsungsun Posts: 1,376Ansys Employee

    Lumerical API with Python works with built-in Python. So please uninstall your own version of Python.

  • johnrollinsonjohnrollinson Posts: 6Member
    edited June 3

    I have already configured my IDE to use the python interpreter provided by Lumerical:


    So I'm not sure that this is related to the version of Python

  • LitoLito Posts: 212Ansys Employee


    Our bundled Python cannot install additional modules in case your script is using one that is not included in our package. You can use your own Python3 installation and include the path for the Lumerical API/module in your environment. 




  • johnrollinsonjohnrollinson Posts: 6Member


    I have tried both way (using my own version of python and explicitly including the lumapi path, or just using the version of python provided by Lumerical) and I get the same error using both methods.

    The error output is from lumapi, so there I don't think there is any issue importing the module.

    The error output indicates that the script gets to the point of trying to open an FDTD instance (self.handle = open(product, key, hide, serverArgs)). For reasons which are unclear to me, this line is failing when I run a script outside of Lumerical (e.g. from either command line or from an IDE) but passes when I run it from the Lumerical GUI (from the script file editor).

    Just to be clear, in the past I have never had any issues running python scripts outside of the Lumerical GUI. This issue only started appearing this week, even though as far as I am aware, there have been no changes to my python environment.

  • LitoLito Posts: 212Ansys Employee


    Were you using a different older version before this issue happen? Or the currently installed version was working before and the issue just recently happened?

  • johnrollinsonjohnrollinson Posts: 6Member

    Previously I was using an older version (I believe it was either 2020 R2.4 or 2021 R1 but I can't remember). The issue then started while I was using the older version. We updated to the latest version hoping this might fix the issue, however it has not. The only thing which has changed after updating is the error that Python is reporting (presumably due to changes in the error handling for the updated the lumapi module). But the line at which the code is failing is still the same.

  • seekjim20seekjim20 Posts: 1Member

    We have the same problem with MODE SOLUTION (Version 2021), it reports

    "LumApiError: 'appOpen error: \n Failed to start messaging, check licenses...'" 

    We previously used 2019b and 2020a, and did not have this issue. It only came up when we upgraded to 2021.

    The MODE Solution window actually opens properly. It is just that it does not return the proper handle back to Python, and thus we can not continue from the Python script.

  • LitoLito Posts: 212Ansys Employee

    @seekjim20 ,

    Please configure Lumerical 2021 R1 to obtain the license from the correct License Manager. Either Lumerical (Standard) Or Ansys (Standard). Consult your IT/license server admin which license manager is running on the license server you are accessing.



  • mrPhotonmrPhoton Posts: 1Member, Unconfirmed

    Unfortunately we are also experiencing this same problem and it is worth mentioning that we never had this problem in pre 2021 releases. The fault is intermittent, and periodically breaks for various Lumerical products. Several of our users have all independently verified that they have configured their licenses properly and have experienced the same problem with the API. It appears not to be license configuring issue from the user but a fault from the python API establishing a connection with the software.

    We have observed this issue on both Linux (CentOS7) and Windows 10. I can guarantee that the software license is correctly configured as if we set the license to the incorrect web address, the user is not able to load the GUI (as expected), and neither is the automation API. When the license is correctly configured users may manually open the GUI without issue. The automation API also causes the GUI to open without prompting for a license, however the simulation handle initialization (i.e. mode = lumapi.MODE(), fdtd = lumapi.FDTD()) does not run correctly and the handle to the simulation is not assigned to to a variable in python and subsequent operations cannot be performed.

    To further illustrate that the error is intermittent, (and also the fact that the license is correctly configured) please see the following traceback, where interaction with FDTD is fine, but MODE which is configured with the same floating license, opens the GUI but fails to establish a connection with lumapi on Linux CentOS7:

    >>> import lumapi
    >>> fdtd = lumapi.FDTD()
    >>> fdtd.addrect()
    <lumapi.SimObject object at 0x7f0c2664af70>
    >>> fdtd.delete()
    >>> fdtd.close()
    >>> mode = lumapi.MODE()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/opt/lumerical/v212/api/python/", line 1303, in __init__
        super(MODE, self).__init__('mode', filename, key, hide, serverArgs, **kwargs)
      File "/opt/lumerical/v212/api/python/", line 1076, in __init__
        self.handle = open(product, key, hide, serverArgs)
      File "/opt/lumerical/v212/api/python/", line 238, in open
        raise LumApiError(error)
    lumapi.LumApiError: 'appOpen error: \n Failed to start messaging, check licenses...libGL error: No matching fbConfigs or visuals found\nlibGL error: failed to load driver: swrast\n'
    >>> mode.addrect()
    Exception ignored in: <function Lumerical.__del__ at 0x7f0be05633a0>
    Traceback (most recent call last):
      File "/opt/lumerical/v212/api/python/", line 1174, in __del__
    AttributeError: 'MODE' object has no attribute 'handle'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'mode' is not defined
  • LitoLito Posts: 212Ansys Employee
    edited August 5


    From your post, it seems that you are running the script from python on the terminal. Are you using your installation of python3? Does the script work when this is run from the GUI using the script editor using the Lumerical bundled python?

    Copy and paste the output of the following:

    cat ~/.config/Lumerical/License.ini 
    cat /opt/lumerical/v212/Lumerical/License.ini
    env | grep LICENSE_FILE
    env | PATH
  • LitoLito Posts: 212Ansys Employee

    If you run the script outside the Lumerical CAD/GUI using your Python3 installation. Ensure that your have the Lumerical "bin" and "api" install folders in your PATH and PYTHONPATH. And your installation of Python3 has the modules required by the Lumerical API and those that are required by your script.

  • ad513649ad513649 Posts: 1Member

    I have the same exact issue and it has appeared all of sudden. It was working fine until 2 days back and without any changes to the installation it seems to have thrown this error.

  • LitoLito Posts: 212Ansys Employee

    @ad513649, Were there any updates to your OS? Or did you update Lumerical? Send the screenshot of the error message and your Python integration status window.

Sign In or Register to comment.