Support Forum

Python Scripting with External Editor

Wednesday 17th March 2021
Hello, I am looking to use python to interface with LayoutEditor to help with semi-automated generation of chip layouts. I have access to a full license for LayoutEditor. I have successfully run the example script inside of the built in text editor. While this is quite useful, I would much prefer to write my code in an IDE, (in my case, VSCode or Atom). In the text editor, I'm not able to import modules that are present on my system install of python, so I guess that this is using a python .exe that is bundled with the software? Is it possible to use this package with my own python environments? In particular, does anyone have experience setting this up with the Anaconda distribution? I found[ this package]( which can be installed with pip to any environment, but it is unable to find the install of LayoutEditor in that case. I have tried modifying Environment Variables also, but its not clear what they should be; > LayoutScript for Python is available for Windows, Linux and Mac. It is included in the Windows packages, in all Linux packages and in the package for Mac OS systems. To use LayoutScript from outside the LayoutEditor set the enviourment variables PATH, LD_LIBRARY_PATH, PYTHONHOME and PYTHONPATH to the correct values before starting python. What are the correct values? Any advice would be much appreciated. Cheers!
Wednesday 17th March 2021
Hi, Python module are sensitive to the used Python version. A (binary) module compiled for Python versiion X will not run with Python version Y. On Mac or Linux system you don't need to care this issue. The LayoutEditor always uses the Python version the system ships natively. So any IDE using the native Python installation is fine to use. Just PATH, LD_LIBRARY_PATH, PYTHONHOME and PYTHONPATH needs to be adjusted in a way that the LayoutEditor installation is found. There are no fixed values for these environment setting as it may depend on your system. To find the correct values I recommend to start a Python script from the build in TextEditor and read out these values. On Windows it is totally different. Windows do not come with a Python installation. Any IDE available comes with its own Python version and mixing (binary) Python modules will get almost impossible. The only way to get it running is to find a IDE supporting the same Python version of your LayoutEditor installation. Alternative you need to switch the IDE to the Python package shipped with the LayoutEditor.