It looks like you're new here. If you want to get involved, click one of these buttons!
Hi Matthias,
Half a year ago I used the standalone python module without problems but totally forgot how did I install it. Now I have made a new install (pip install klayout) and downloaded the klayout-bits-1.0 and modified the PATH as per instructions in
https://github.com/KLayout/klayout/wiki/KLayout-Python-Module.
Now
import klayout.db
gives me
ERROR: Unable to load plugin: \ANACONDA3\lib\site-packages\klayout\db_plugins_lefdef_dbpi.cp36-win_amd64.dll with error message: 127 ERROR: Unable to load plugin: \ANACONDA3\lib\site-packages\klayout\db_plugins_pcb_dbpi.cp36-win_amd64.dll with error message: 127
and the popup says that dll entry cannot be located.
I guess I am missing something trivial - could you help me?
Thank you.
Mikhail
Comments
Installing klayout-0.26.0.dev8-cp36-cp36m-win_amd64.whl instead of
klayout-0.26.0.dev16-cp36-cp36m-win_amd64.whl
solved the problem!
However, when I try to use pyinstaller, and run the resulting .exe I get:
RuntimeError: Unknown stream format: GDS2 in Layout.write
???
HI mikhails,
dev8 is too old. It lacks some files that's why the GDS reader can't be found.
You can dry to install dev16 and delete the "db_plugins_pcb_dbpi.cp36-win_amd64.dll" if you don't need support for PCB formats (Gerber).
I'll try to reproduce the issue. But Windows is a pain.
Matthias
Thanks, Matthias!
Another related question if I may. I have a python macro, converting a custom polygon format to GDS. If I run it as
Measure-Command {klayout_app.exe -z -r convert_poly_to_gds.py -rd infile=test.poly -rd outfile=test.gds}
gives:
TotalSeconds : 0.0066875
Now, I change it to use standalone python module (basically, only imports are changed from "import pya" to "import klayout.db as db" and run as
Measure-Command {python convert_poly_to_gds_python.py test.poly test.gds}
gives:
TotalSeconds : 1.196693
Computed results are correct in both cases.
Why this enormous difference? I hoped for the opposite...
I am using Anaconda Python 3.6 on Windows 10.
Hi mikhails,
I don't think the 6ms are correct in the first case. "klayout_app" is a big binary. It will load many shared objects and loading it should take much more than 6ms. On the other hand, "import klayout" pretty much does the same - at least for some shared objects. I observed long times for "import klayout.db" too. Depending on the system, some shared objects may be cached, so load times may vary.
But essentially, the times you measure seem to be related to interpreter initialization, not execution time of your application.
Matthias
Hello Matthias,
Congrats for the great python module - it works awesome inside anaconda !
I'm on the way too finalize now a larger project for Mask Generation and WaferMap optimization. I use the python standalone module to run all the different steps and the normal layout GUI to run some verification and optimization steps. Looking forward to see the further development.
Best Regards,
Andy
Hi Andy,
Thanks a lot this feedback! I really appreciate this!
Kind regards,
Matthias
Hi Matthias ,
I got a similar problem with mikhails when packing my python file using Pyinstaller.
It shows:
" RuntimeError: Cannot determine format from filename in Layout.write"
Is there any suggestion?
I am using Python 3.6.8 on Windows 10.,
klayout-0.26.0.dev16-cp36-cp36m-win_amd64.whl.
Thanks.
Hi,
I think this is a different issue. What's the filename you give to Layout.write? It needs to be "gds2", "oas", "cif" or similar to be recognizable.
If you want a specific format, use a "SaveLayoutOptions" object and specify a format. Then pass this object to "write".
Matthias
Hi Matthias
I just use " layout.write('test.gds') "
It works perfectly directly using the script inside KLayout or in standalone python module.
It just failed when I compiled my standalone script using Pyinstaller...
And shows " RuntimeError: Cannot determine format from filename in Layout.write"
I could not figure it out...
Is there any other suggestion??
Thank you for your kindly help.
I see.
I think this is related to the stream plugins then.
For a brief explanation: KLayout loads the stream format dynamically from shared objects found next to the "db" library in a directory called "db_plugins". This directory should contain the reader libraries. On Linux they are called "libgds2.so", "liboasis.so" etc.
Essentially a Python module is made from this components:
<PYTHONPATH>/klayout/db/__init__.py
- the initial loader<PYTHONPATH>/klayout/dbcore.so
ordbcore.dll
libklayout_db.so
orklayout_db.dll
through the system's dynamic linker.<path-to-itself>/db_plugins/*.so
or*.dll
and load them to establish the stream readers and writers.So I assume that the latter step does not find a valid stream plugin. If these libraries are there, maybe they are not loaded because some dependency is not satisfied. On Linux "ldd" can give you more details, on Windows that's the dependency walker.
I hope this helps further,
Matthias
Hi Matthias
Follow your suggestion,
I modified my .spec file (use for Pyinstaller) with binaries file link.
And then it worked!!
I appreciate all you do.
Thank you very much.
Very good and thanks for this feedback :-)
Matthias
Yes, this worked for me as well.
Many thanks to duncanusn and Matthias!