GDS open issue

Hi, I am trying out the macros, starting with the sample code listed on the website. I face an error showing the unable to open the .gds file (errno: 13). I made sure that the code file is in the same path. But not sure, why the error is?



  • Is there a listing of all the klayout errors that could be thrown,
    with probable causes, anywhere in the docs-pile?

    I didn't find anything in the Assistant, but I can't call that a
    surprise. No search hits in the online manual either.

    If not, it would make a nice Appendix....

  • @Rakesh

    Did you read the error message? Where is KLayout supposed to store the file? The notation you used means (in unix and I think even POSIX) use the current folder, which under windows would (most likely) be C:\Program Files\KLayout\t.gds if even supported and looking at the source code it's not the case for Windows (could be mistaken when glancing over it though), which as you can guess is a bad idea and would require administrator rights. You should add a path, e.g. C:\Users\Rakesh\Documents\t.gds and then it should work

    @dick_freebird sure there is :) these are the standard POSIX errors which is exactly what KLayout is throwing (in this case and others where standard errors apply)

    you can get the error with for example python

    import errno

    But I mean in this case it is a bit useless to do that as the error message already tells you what is wrong.

  • Hi Sebastian,
    I created a separate folder "D:/klayout_tests" where the script file is saved. I created an empty gds file 't.gds' in this same folder. Then after clicking run, I get the same error. In your suggestion of adding a path: do you mean anything else? I posted the image of the file with the folder where files are stored.
    The t.gds has a rectangle added to it after running the code, but the error prevails. Can you comment on this?


  • @Rakesh

    write("t.gds") will use the current directory which can basically be anywhere. On Windows, you can configure the shortcut to specify the directory where a program starts in and by default I think it's the installation path. If that path isn't your own, it's likely you won't be able to write there.

    Use a full path like


    Both forward- and backward slash paths work. For backslash you have to use double backslash because a single backslash has a special meaning in Python strings:


    You can also use environment variables and system-independent path manipulation like this:

    import os
    layout.write(os.path.join(os.getenv("HOME"), "t.gds"))


Sign In or Register to comment.