Support Forum

Scripting LayoutEditor in Python with PyCharm on a Windows 10 machine

Paul

Sunday 18th August 2019
I'm trying to use PyCharm to script LayoutEditor in Python on a Windows 10 machine. In PyCharm, I set the interpreter to "C:\Program Files (x86)\LayoutEditor\python\python37\python.exe". In my Python script, the line "import LayoutEditor" fails because the Windows path in "C:\Program Files (x86)\LayoutEditor\python\python37\Lib\site-packages\LayoutEditor\_init.py" is not referenced to the root directory ("dir="Program Files (x86)/LayoutEditor/python" instead of "dir="C:/Program Files (x86)/LayoutEditor/python"). If I manually edit init.py to correct this, it them fails with the error message "ops, there was a problem load LayoutScript for python". The files "LayoutScript.pyd", "LayoutScript.pyw", and "oaxLayoutScript.py" are in "C:\Program Files (x86)\LayoutEditor\python\". Please help, thanks, Paul.
Jürgen
LayoutEditorFull
Monday 19th August 2019
Hi Paul, I don't know PyCharm, but in general some enviorrnments had to be set: * for Windows: * PATH must include the*LayoutEditor/bin/ *folder to be able to find the required dll * PYTHONPATH must include the *LayoutEditor/python* folder to find the LayoutEditor Python module * to use OpenAccess file format PATH must also contain the *LayoutEditor/oa/bin/ ....* folder with the dll file (differ a bit for 32bit and 64 bit systems) * for Linux: * LD_LIBRARY_PATH must include the *LayoutEditor/lib* path and for OpenAccess the *LayoutEditor/oa/lib/* path * PYTHONPATH must include the *LayoutEditor/python* folder to find the LayoutEditor Python module The integrated TextEditor will set these variables automaticly when calling a Python script
Paul

Monday 19th August 2019
Hi Jürgen, I followed your instructions, it works, problem solved! Thanks so much for the quick response, Paul.