How to load Layouts from Links (Windows)

Given a Layout at: C\Users\whatever\layout.gds and creating a shortcut to it (Win: right-click -> create shortcut).
How can this shortcut be loaded?

import pya
# works
# does not work
pya.Layout().read(path + ".lnk")

The error I get is: RuntimeError: Stream has unknown format: ...lnk in Loading the .lnk file in KLayout GUI using File -> Open works fine however.
How can I load the shortcut in python similar to how it is done in the GUI?
Thanks! :)


  • edited April 16

    Hi @Peter123,

    I am sorry, but that is not supported natively.

    Unlike Unix, on Windows, a link (*.lnk) is not handled by the file system, but by the shell. A "lnk" file is a binary file, nothing more, so an application needs to be coded in some special way to support it (see for example Apparently, the "Open" dialog resolves the "lnk" file to the destination.

    There is Python code available which resolves the links (, pylnk3 module). You can copy into c:\users\your_name\KLayout\python to make this module available. There is no thing such as "pip" in a standalone KLayout installation.


  • edited April 17

    Hello @Matthias,

    Thank you for the info. I learned a new technique today :smiley:
    I found I should copy into c:\users\your_name\KLayout\lib\python3.11\.


  • Hi @sekigawa,

    That is interesting, but it is kind of unintended ... I need to check myself why this is working. It may depend heavily on Python internals which is not good as it would change with other Python versions :(



  • edited April 17

    Hello @Matthias,

    Oops, it's my mistake. My above description was incorrect. Sorry about that.
    I placed in the system's Python library, as shown below.

    I assumed needed to be treated as a part of the system's Python.

    I moved to c:\users\your_name\KLayout\python ($HOME/.klayout/python/ in the Linux|Mac env.).
    Then, it still works as you intended.

    Thank you.

  • Ah, very good. That is what I was expecting! :)

    Thanks for this confirmation.


Sign In or Register to comment.