Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: TelApy dynamic library import problems: No module named '_api'

TelApy dynamic library import problems: No module named '_api' 2 years 8 months ago #39947

Dear All,

I am quite new in the use of Telemac2d and despite the fact that I successfully performed some simulations, I would like to implement dynamic simulations using some user defined python scripts.

I followed the python for Telemac documentation link and when I run:
my_case = Telemac2d('t2d_breach.cas', lang=1, comm=MPI.COMM_WORLD)

The next output is printed:
TelemacException: Error: unable to load the dynamic library _api.so
You can check the environment variable: PYTHONPATH
No module named '_api'

I have checked the PYTHONPATH and the next output:
$ echo $PYTHONPATH
/home/marcelo/opentelemac-mascaret/v8p3r0/builds/gfortranHPC/wrap_api/lib:/home/marcelo/opentelemac-mascaret/v8p3r0/scripts/python3:/home/marcelo/opentelemac-mascaret/v8p3r0/builds/gfortranHPC/wrap_api/lib:/home/marcelo/opentelemac-mascaret/v8p3r0/scripts/python3:

I checked the solution of this thread, but I think it is not the same problem.

I will appreciate your help very much.

Regards,

Marcelo
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 2 years 8 months ago #39956

  • pham
  • pham's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1559
  • Thank you received: 602
Hello Marcelo,

You seem to have a problem with your installation.
Have you include api to options in your systel.cfg file?

You can have a look at S9.gfortran config in $HOMETEL/configs/systel.edf.cfg file, it works.

Hope this helps,

Chi-Tuan

PS: I move your topic in the installation section.
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 7 months ago #42327

Hi,

I am getting the same error, but cannot find an issue with my cfg file. The edf.cfg file uses Debian9/10 configs, so they won't work on my Debian11-based platform, I guess. Does anyone have an idea what could be the issue?

Best,
Sebastian
Attachments:
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 7 months ago #42336

Dear Sebastian,

I fixed the issue. Before using python you have to source your pysource file:

$ source pysource.gfortranHPC.sh

If the error keeps raising up, you might have forgotten to compile some addon library. I had to compile all the additional libraries to make it work.

You can check it here:

wiki.opentelemac.org/doku.php?id=installation_on_linux

Kin regards,

Marcelo
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 7 months ago #42340

Hi Marcelo,

Thanks for your reply. I guess that without source-ing the bash file, nothing works anyway.

The pysource.gfortranHPC.sh bash file points to the edf config, which seems to be designed for Debian9/10 (S9/10 links) only.

Running telemac from Terminal works fine, but running telemac from Python code (e.g., as described in v8p4/notebooks/telemac2d.ipynb) causes the error, also after double-checking the libraries.

So the issue is still open, and I am grateful for any hint.

Best,
Sebastian
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 7 months ago #42342

Dear Sebastian,

I shared with you my systel.cfg, make sure that all the additional libraries are compiled in dynamic (.so). the configuration is "C9.gfortran.dyn". Make sure to select this configuration in the pysource file in the line
export USETELCFG=C9.gfortran.dyn

For me it works well. However, compiling and installing all additional libraries in .so can be tedious. Afterwards, TelApy works really well even in parallel computing using mpirun.

File Attachment:

File Name: systel.cfg
File Size: 7 KB
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 7 months ago #42346

Hi Marcelo and anyone interested,

Finally, I resolved the issue by using systel.edf.cfg with only the modules that I need, but it required resolving a couple of issues:

- The Karypis Lab website for downloading METIS v5.1.0 is down (maybe just a temporary issue). Solution: use their Github repo (github.com/KarypisLab/METIS) to install METIS v5.1.1 along with their GKlib from github.com/KarypisLab/GKlib

- Not use HDF v1.10.7 (in the installation docs, which is incompatible with med v4.0.0) but 1.10.3

- Remove unnecessary library dependencies from systel.edf.cfg

- Use S10.gfortran.dyn (S9 or C9.gfortran.dyn are not available in TM v8p4r0)

The full path to my solution is here:
hydro-informatics.com/get-started/install-telemac.html

Best,
Sebastian
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 7 months ago #42365

  • borisb
  • borisb's Avatar
  • OFFLINE
  • Admin
  • Posts: 128
  • Thank you received: 64
Hi Sebastian,

On Debian 11, if you have sudo rights, the easiest way of installing METIS is to use the package manager:
sudo apt install libmetis-dev
The administrator has disabled public write access.
The following user(s) said Thank You: nicogodet, sebastian.schwindt

TelApy dynamic library import problems: No module named '_api' 1 year 5 months ago #42662

  • wsy9208
  • wsy9208's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 37
  • Thank you received: 3
Hello Sebastian,

I have encountered the same issue as you. It works fine when I first source the pysource file in the terminal and then call "python3 xx.py", but it doesn't work when I directly run the Python file in PyCharm. I followed the instructions you mentioned in your previous response, specifically the ones from the website hydro-informatics.com/get-started/install-telemac.html, using S10.gfortran.dyn. However, the problem still persists. I am using Ubuntu 16.04.1(TELEMAC V8P4). I would greatly appreciate any advice or suggestions you may have.

Thank you very much!

Kind regards,
WSY
The administrator has disabled public write access.

TelApy dynamic library import problems: No module named '_api' 1 year 5 months ago #42663

Hello,

I found the challenge was to standardize a combined loading of Python environments, that is, first the Telemac environment and second another environment that I require for running a Python package that I am currently developing. PyCharm can be set up for doing this, but it does not work consistently when I am working on different projects for which I do not need these double environments. So, here is my solution:

- I wrote a bash script (see attachment) that first receives the directory where my Telemac configs live (line 3)
- line 4 defines the Telemac config file name
- line 5 defines the directory where the environment lives, which I need to develop my package (in this case: "HBCenv" with some machine learning libraries)
- all other lines are just functions that finally activate the two environments
- the most consistent solution is to open Terminal in the directory where this bash file (activateHBCtelemac.sh) is stored and then tap:
source activateHBCtelemac.sh
- now, develop your code in PyCharm and test-run it in Terminal (e.g., tap: python my_code.py, or start a Jupyter notebook from this Terminal).

It also works with some PyCharm settings, but it's not straightforward. Otherwise, you could also implement the bash script in your ~/.bashrc, but this can mess up your system.

I hope this helps.

Best,
Sebastian
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.