TAGGED: fdtd, python, python-scripting
-
-
July 18, 2022 at 8:56 pm
mo_911
SubscriberHello, I just wanted to follow the steps on the page "Inverse design of y-branch" (https://optics.ansys.com/hc/en-us/articles/360042305274), but step 1 of 1 is not working. I have checked that "Python Integration Status" is active and the box "Use Python provided by Lumerical" was checked. Then I opened the sample python file "varFDTD_y_branch.py" and ran it from the CAD/GUI Script File Editor, but I got a syntax error even in the first line "import lumapi". I suspect that the python is not running. I am wondering how to fix this issue. Please find attached the screenshots related to this issue. Thanks. -
July 19, 2022 at 5:08 am
jackzhf
Subscriberlumapi might be missing and here is some helpful information:
”
- Working directory : It should be possible to store the files in any locations as desired. However, it is recommended to put the Lumerical and Python files in the same folder in order for the above script files to work properly. It is also important to check the Lumerical working directory has the correct path, see here for instructions to change the Lumerical working directory.
- Linux: /opt/lumerical/interconnect/api/python/
- Windows: C:\Program Files\Lumerical\FDTD\api\python
During the Lumerical product installation process, a lumapi.py file should be automatically installed in this location.
This module is the key to enable Lumerical-Python API connection. Once the lumapi module is imported to Python, the integration should be read.”
https://optics.ansys.com/hc/en-us/articles/360034416574-FDTD-application-example
https://optics.ansys.com/hc/en-us/articles/360041873053-Session-management-Python-API
https://optics.ansys.com/hc/en-us/articles/360037824513-Python-API-overview
- Working directory : It should be possible to store the files in any locations as desired. However, it is recommended to put the Lumerical and Python files in the same folder in order for the above script files to work properly. It is also important to check the Lumerical working directory has the correct path, see here for instructions to change the Lumerical working directory.
-
July 19, 2022 at 4:49 pm
Guilin Sun
Ansys EmployeeDo you use your own Python? If you independently download and install your own version, this can happen. We recommend to uninstall your own phyton, reinstall Lumerical software, and in most case it will work, as Lumerical package has the correct Python version and configurations. Otherwise you will need to reconfigure the phyton and other settings, which are not that easy and obvious.
-
July 19, 2022 at 5:24 pm
mo_911
SubscriberHi jackzhf,
Thank you for your reply.
I found that a lumapi.py file was already installed at a location "/opt/lumerical/v221/api/python" (please see the screenshot attached).
After changing the Lumerical working directory to the location above, I still got the same error even in the first line "import lumapi" (please see the screenshot attached).
I am suspecting that even the python command "import" is not working.
Thanks
-
July 19, 2022 at 5:29 pm
mo_911
SubscriberHi Guilin Sun,
Thank you for your comment. No, I have not installed my own python. That's why I want to use the python that was automatically installed with Lumerical. As I showed in my first post, the python integration status is "active" on Lumerical, but it looks like even the python command "import" is not working.
Thanks.
-
July 19, 2022 at 5:32 pm
Guilin Sun
Ansys EmployeeYou did not reply me if you installed your own python or use the software package? Please uninstall the python you installed, and reinstall lumerical package: unintal first, restart the computer, and sometimes you may need a clean installation. please refer “clean installation” https://optics.ansys.com/hc/en-us/articles/5613618572947-Fixing-installation-or-license-activation-issues
Please note that using the packaged python, you do not have the python GUI.
-
July 19, 2022 at 5:49 pm
Lito
Ansys Employee@mok,
Try to set your PATH and PYTHONPATH environment variables. See these KB guides for details.>https://optics.ansys.com/hc/en-us/articles/7595785040403-Setting-environment-variable-in-Linux
>https://optics.ansys.com/hc/en-us/articles/5771091294739-How-to-run-Lumerical-API-Python-scripts-in-Linux
-
July 19, 2022 at 5:55 pm
mo_911
SubscriberHi Lito Yap,
Thank you for your comment. Yes, I can try to install the latest release later, probably tomorrow with our administrator. I will let you know when I install it.
Thanks
-
July 19, 2022 at 6:06 pm
mo_911
SubscriberHi Lito Yap,
I created a new brank python file named "220719_Test_Script.py" and copied the commands you wrote to it. Then I opened the file on Lumerical Script Editor and ran it. Then the terminal window showed up and then the Lumerical FDTD window showed up as well. I think that both python and lumapi are working with these commands.
Thanks
-
July 19, 2022 at 6:12 pm
Lito
Ansys Employee@mok,
Try to set your PATH and PYTHONPATH environment variables. See these KB guides for details.>https://optics.ansys.com/hc/en-us/articles/7595785040403-Setting-environment-variable-in-Linux
>https://optics.ansys.com/hc/en-us/articles/5771091294739-How-to-run-Lumerical-API-Python-scripts-in-Linux
-
-
July 19, 2022 at 6:14 pm
mo_911
SubscriberHi All,
I created a new blank python file named "FDTD_y_branch_test.py" and copied the lines 1 - 20 of the Lumerical sample python file "varFDTD_y_branch.py" to it. Then I opened the file on Lumerical Script Editor and ran it. Then the terminal window showed up and it says "ImportError".
After reading the messages shown in the terminal, I realize that another python was already installed with "Cadence" that was installed on the same linux machine. I guess this is the reason why the Lumerical sample python file "varFDTD_y_branch.py" is not running properly, but I do not know how to fix this issue.
Thanks
-
July 19, 2022 at 6:36 pm
Lito
Ansys Employee-
July 19, 2022 at 7:32 pm
mo_911
SubscriberI am just wondering why you recommended removing ".ini" file. I found that there are multiple ".ini" files. Should only "FDTD Solutions.ini" be deleted in this case?
-
-
July 19, 2022 at 6:37 pm
mo_911
Subscriber-
July 19, 2022 at 6:56 pm
jackzhf
SubscriberNice. You may need to fix similar issue if you use python with Cadence in the future.
-
July 19, 2022 at 7:24 pm
mo_911
SubscriberThat's true. I will try to solve this issue without deleting the path later.
-
-
-
July 19, 2022 at 6:41 pm
Lito
Ansys EmployeeGreat! ??
-
July 19, 2022 at 6:54 pm
mo_911
SubscriberThank you all for your prompt replies and comments!!
-
- The topic ‘Python script is not running from CAD/GUI Script File Editor of Lumerical FDTD’ is closed to new replies.
-
3572
-
1193
-
1076
-
1063
-
952
© 2025 Copyright ANSYS, Inc. All rights reserved.