|
[Sponsors] |
August 15, 2022, 23:54 |
ImportError: pysu2
|
#1 |
New Member
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 6 |
Hello there,
I have been using SU2 version 7.0.4 for quite some time now. My main objective is to run SU2 through a python script. I tried to enable the python wrapper by the command: $ . /configure --enable-PY_WRAPPER. There were no errors and no warnings, I also noticed that the _pysu2.io file and pysu2.py script were added to the location /usr/local/bin, so the enabling seemed successful. However, when I try importing pysu2 by the command: import pysu2 in a python script, the following error message occurred: ImportError: /usr/local/bin_pysu2.so: undefined symbol: ZSt28__throw_bad_array_new_lengthv I have attached an image of the complete error with the line numbers. Could you kindly help me figure out why exactly this error is popping up and how I should proceed to fix it? -- Some information regarding the system/software: Ubuntu version: 22.04 SU2 version: 7.0.4 (Built from source) gcc version: 11.2.0 python version: 3.7.6 swig version: 3.0.12 Codes are run only in serial. Environment variables are already set up as follows: export SU2_RUN="your/prefix/bin" export SU2_HOME="/path/to/SU2" export PATH=$SU2_RUN:$PATH export PYTHONPATH=$SU2_RUN:$PYTHONPATH Last edited by Vishnu Sankar; August 15, 2022 at 23:58. Reason: Title of the error was wrong |
|
August 17, 2022, 17:13 |
|
#2 |
Senior Member
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21 |
This is I think due to a mismatch between the python version (or compiler) used to compile pysu2 and the python version (or compiler) that is used to run the program. If you do the library import for instance from inside a conda environment that was not used to compile pysu2, there will be a mismatch (usually in a library like libstdc++).
So the first thing is to check the python version used to compile pysu2, and then check that this is the same as the environment you are importing into. |
|
August 22, 2022, 05:07 |
|
#3 |
New Member
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 6 |
Hey!
I am trying to run SU2 through spyder available in Anaconda. It uses python version 3.7.6 to compile pysu2. To check if this is the same as the environment I am importing it into, I closed spyder and checked the python version in the 'base' environment (which is the same environment in which I opened spyder). I also deactivated the 'base' environment to check what's the default version of python outside the 'base' environment, it is also python 3.7.6. I hope I have done as you said, if I did anything wrong, please do let me know as I do not have much experience working with Linux OS. Incase I have done as you said, is there anything else that I might be missing or need to look at to resolve the "ImportError" of pysu2? Thank you! |
|
August 28, 2022, 19:11 |
|
#4 |
Senior Member
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21 |
if you are in the terminal where you just compiled SU2, can you try to start python directly there from the command prompt, and simply type "import pysu2" in the python terminal? Does that work for you?
|
|
September 4, 2022, 18:57 |
|
#5 |
New Member
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 6 |
Hey!
I tried that out, but still got the same error. Thanks a lot for helping out. I got help from my department system admin, and everything is sorted now. When I try to enable the Python wrapper, it installs the required files inside SU2. But python was never able to locate some packages created by meson. So I had to specify the path of the python site-packages directory where all python packages were installed. Here are the steps:- Since I was using miniconda3, all the packages were installed in: /home/vishnu/miniconda3/pkgs . So the right command to build the meson file is: ./meson.py -Denable-pywrapper=true --prefix=/home/vishnu/SU2 build -Dpython.platlibdir=/home/vishnu/miniconda3/pkgs -Dpython.purelibdir=/home/vishnu/miniconda3/pkgs Then I added the SU2 paths in bashrc. Now I installed ninja with: ./ninja -C build install Now I could import pysu2 without any errors. Ref links:- https://github.com/ev-br/mc_lib/issu...ent-1003572421 https://github.com/ev-br/mc_lib/issues/45 Thanks a lot! |
|
Tags |
pysu2, python wrapper |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[RapidCFD] Discussion thread on how to install and use RapidCFD | newoscar | OpenFOAM Community Contributions | 88 | May 17, 2024 10:39 |
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' | muth | OpenFOAM Running, Solving & CFD | 3 | August 27, 2018 05:18 |
Can someone PLEASE document the development version installation | bernd | OpenFOAM Installation | 76 | November 14, 2008 22:51 |
Regarding FoamX running Kindly help out | hariya03 | OpenFOAM Pre-Processing | 0 | April 18, 2008 05:26 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |