Problem with CSXCAD and python interface

Install support for openEMS

Moderators: thorsten, sebastian

Post Reply
valege
Posts: 3
Joined: Thu 31 Mar 2022, 19:11

Problem with CSXCAD and python interface

Post by valege » Thu 31 Mar 2022, 19:46

Hello,

I manage to install openEMS on ubuntu 21.10 (impish) with a little bit of work (the first part is hopefully helpful for some people).
I think its officially not supported and for some reason cmake does not find CSXCAD during installation of QCSXCAD which can be fixed by installing it manually and providing the path to the include file. On my installation cmake did not find libdl which is under /lib/x86_64-linux-gnu/libdl.so while cmake searches in /usr/lib/x86_64-linux-gnu/libdl.so (probably some difference between distributions?) but copying the file to the search folder (/usr/lib/...) did work for me.
the following command did install QCSXCAD correctly (being in the unpacked QCSXCAD folder - I have all the files in /opt/openEMS not in ~/opt/openEMS)

Code: Select all

sudo cmake ../ -DCMAKE_INSTALL_PREFIX=/opt/openEMS/ -DCSXCAD_ROOT_DIR=/opt/openEMS/ -DCSXCAD_INCLUDE_DIR=/opt/openEMS/include/CSXCAD/ -DCSXCAD_LIBRARIES=/opt/openEMS/lib/
afterwards i could create AppQCSXCAD (with the same command in the AppQCSXCAD folder) without problems and the first few tutorials went without problems, so octave & openEMS with QCSXCAD/AppQCSXCAD seem to work fine.

because cmake throws an error while installing QCSXCAD I think the python interface (and MPI?) are not installed because they are installed after QCSXCAD.
Now I wanted to install the python interface by

Code: Select all

python3 setup.py build_ext -I/opt/openEMS ... -L/opt/openEMS -R/opt/openEMS
which does not throw any error, afterwards I can use
sudo python3 setup.py install
and the python files appear in /usr/local/lib/python3.9/dist-packages/openEMS-0.0.33-py3.9-linux-x86_64.egg/openEMS/ which seems to be correct (and seems to be in the pythonPATH)
now when I try to use

Code: Select all

import openEMS
in python I get an import error "/usr/local/lib/python3.9/dist-packages/openEMS-0.0.33-py3.9-linux-x86_64.egg/openEMS/__init__.py" line 7, in <module>
import CSXCAD
ModuleNotFoundError: No module named 'CSXCAD'

the file itself says
# try to import CSXCAD, e.g. make sure the (windows) dll path are set
before the import statement

so what could have gone wrong during the installation, im a little bit lost here? The CSXCAD library works (well at least the openEMS tutorials work), QCSXCAD and AppQCSXCAD work but somehow the python installation can't find the library?

thorsten
Posts: 1515
Joined: Mon 27 Jun 2011, 12:26

Re: Problem with CSXCAD and python interface

Post by thorsten » Sun 03 Apr 2022, 10:02

Hi,

did you try to just follow the instructions on github?
https://github.com/thliebig/openEMS-Project#readme

In any case for each "module" you can create a file called "localConfig.cmake" (next to the main CMakeLists.txt with e.g. the following content (for openEMS).

Code: Select all

SET(WITH_MPI 0)
SET(FPARSER_ROOT_DIR /usr/local)
SET(CSXCAD_ROOT_DIR /opt/openEMS)
SET(CMAKE_INSTALL_PREFIX /opt/openEMS)
For CSXCAD you would of course not have the "CSXCAD_ROOT_DIR" and so on...


For the python build, it should be:

Code: Select all

python setup.py build_ext -I/opt/openEMS/include -L/opt/openEMS/lib -R/opt/openEMS/lib"
as should be documented in the python/README.md
You are missing the ".../lib"

The "-R" tells it where to find the libraries at runtime...

regards
Thorsten

thorsten
Posts: 1515
Joined: Mon 27 Jun 2011, 12:26

Re: Problem with CSXCAD and python interface

Post by thorsten » Sun 03 Apr 2022, 10:04

I just noticed, did you build the CSXCAD python interface?? You need to build and install *both* the CSXCAD and openEMS python interfaces...

thorsten
Posts: 1515
Joined: Mon 27 Jun 2011, 12:26

Re: Problem with CSXCAD and python interface

Post by thorsten » Sun 03 Apr 2022, 10:06

I want to reiterate, if you just want to use openEMS, I recomment using the premade scripts from github:

Code: Select all

git clone --recursive https://github.com/thliebig/openEMS-Project.git
cd openEMS-Project
./update_openEMS.sh ~/opt/openEMS --python
And I recommend not to install/use as root. Only if you really need to share it with other users maybe...

valege
Posts: 3
Joined: Thu 31 Mar 2022, 19:11

Re: Problem with CSXCAD and python interface

Post by valege » Mon 04 Apr 2022, 02:30

thorsten wrote:
Sun 03 Apr 2022, 10:04
I just noticed, did you build the CSXCAD python interface?? You need to build and install *both" the CSXCAD and openEMS python interfaces...
Thank you very much for your fast reply, I did not build the CSXCAD python interface and this was the problem!

Post Reply