CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2 > SU2 Installation

ImportError: pysu2

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Vishnu Sankar

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2022, 22:54
Exclamation ImportError: pysu2
  #1
New Member
 
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 5
Vishnu Sankar is on a distinguished road
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
Attached Images
File Type: png ImportError pysu2.png (174.5 KB, 26 views)

Last edited by Vishnu Sankar; August 15, 2022 at 22:58. Reason: Title of the error was wrong
Vishnu Sankar is offline   Reply With Quote

Old   August 17, 2022, 16:13
Default
  #2
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 495
Rep Power: 17
bigfootedrockmidget is on a distinguished road
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.
bigfootedrockmidget is offline   Reply With Quote

Old   August 22, 2022, 04:07
Default
  #3
New Member
 
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 5
Vishnu Sankar is on a distinguished road
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!
Vishnu Sankar is offline   Reply With Quote

Old   August 28, 2022, 18:11
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 495
Rep Power: 17
bigfootedrockmidget is on a distinguished road
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?
bigfootedrockmidget is offline   Reply With Quote

Old   September 4, 2022, 17:57
Smile
  #5
New Member
 
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 5
Vishnu Sankar is on a distinguished road
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!
abhijithmoni likes this.
Vishnu Sankar is offline   Reply With Quote

Reply

Tags
pysu2, python wrapper

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[RapidCFD] Discussion thread on how to install and use RapidCFD newoscar OpenFOAM Community Contributions 84 September 2, 2022 01:04
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 04:18
Can someone PLEASE document the development version installation bernd OpenFOAM Installation 76 November 14, 2008 21:51
Regarding FoamX running Kindly help out hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 04:26
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51


All times are GMT -4. The time now is 07:37.