It looks like you're new here. If you want to get involved, click one of these buttons!
Dear all,
I am running Klayout on linux and I can import successfully "openpyxl" into Klayout.
When I run in Windows and I try to import "openpyxl" into Klayout, The tool says"ModuleNotFount: No module namedopenpyxl"
I checked and openpyxl is instaled in my windows system.
I noticed this:
1) If I open a CMD window and run "py" (Python 3.11.2) I can "import openpyxl" without any problem
2) If I open a CMD window and run "python" (Python 3.6.3) I do "import openpyxl" I get the same error as from Klayout: "ModuleNotFount: No module namedopenpyxl"
So it seems that I need to modify the python version Klayout is picking.
I modified the Windows PATH definition and I removed the path to Python 3.6.3. In windows now the problem is fixed as I only get version 3.11.2 and I can import openpyxl...... In Klayout I still can not import openpyxl.
I also uninstalled the Python 3.6.3 version from my Windows system and I still can not import openpyxl.
How do I tell Klayout which Python version should take ? or alternativelly how to import "openpyxl" into Klayout?
Thank you in advance
Best regards
Giovanni
Comments
Hi Giovanni,
you cannot just use another version of Python on Windows. Windows does not have package management and there are multiple flavors of Python that are incompatible on a binary level. One Python cannot use the modules of another.
KLayout is not "picking" some Python, but Python is embedded inside KLayout. So KLayout comes with it's own Python environment which is based on the MSYS2 Posix emulation layer. All packages that are available inside KLayout are ones that I selected and packaged with the KLayout binary. Installing other packages is difficult if not impossible. If there was a list of must-have modules I could try to include them - however, I am afraid that this list was pretty long and integration may be different for other reasons (e.g. matplotlib which needs PyQt5 and conflicts with KLayout internally).
The easiest solution is Linux where KLayout shares the modules with the system Python.
Technically there are solutions for Windows, like packaging KLayout with Anaconda. However, these things are incredibly time consuming and I rather like to spend my efforts elsewhere. A recent effort in that direction stalled. Apart from that, Anaconda packaging would have other side effects that are not desirable, like the dependency on Anaconda.
I have raised a GitHub ticket for a public vote and maybe you can comment there to have openpyxl included: https://github.com/KLayout/klayout/issues/1494
Matthias