CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[Salome] Salome python api

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

Like Tree3Likes
  • 1 Post By AtoHM
  • 1 Post By linnemann
  • 1 Post By Hr_kules

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 5, 2023, 08:37
Default Salome python api
  #1
Senior Member
 
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6
Hr_kules is on a distinguished road
Hi,

i want to use the salome python api, however after installing salome and testing running one of the python examples in vscode, i was only presented with:

ModuleNotFoundError: No module named 'salome'

Does anybody know how to resolve this?
Hr_kules is offline   Reply With Quote

Old   June 5, 2023, 14:16
Default
  #2
Senior Member
 
M
Join Date: Dec 2017
Posts: 698
Rep Power: 12
AtoHM is on a distinguished road
Not tried it with Salome yet, but as I am working alot with Python I like to point out this just means, the Python Environment you are using does not find the salome package. You need to tell your IDE where the environment is you want to use. I assume vscode defaults to some Python environment you might already have on your station or maybe you installed it with one and it is using this?


Usually when developing and debugging api code for other software packages, there are man pages telling you how to set it up for debugging in vs (or other IDEs). So you might find something like this.


For example in FreeCAD to use the integrated Python interpreter, I think the python.exe is located in FreeCAD/bin/ so you would tell your IDE it is located there. Locate the exe and provide the path.
Hr_kules likes this.
AtoHM is offline   Reply With Quote

Old   June 5, 2023, 14:38
Default
  #3
Senior Member
 
linnemann's Avatar
 
Niels Nielsen
Join Date: Mar 2009
Location: NJ - Denmark
Posts: 556
Rep Power: 27
linnemann will become famous soon enough
You have to use salomes own libraries, so you cannot use your system Python. You need to source Salome to set all paths etc. berfore you can do that. Look in the "env_launch.bat" on Windows.



If on windows you can use this command from the installation directory of Salome in the vscode terminal.


Code:
D:\\Software\SALOME-9.10.0\W64\Python\python3.exe salome shell .\dump.py


Where dump.py is your Salome file.
Hr_kules likes this.
__________________
Linnemann

PS. I do not do personal support, so please post in the forums.
linnemann is offline   Reply With Quote

Old   June 6, 2023, 08:06
Default
  #4
Senior Member
 
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6
Hr_kules is on a distinguished road
Hey, thanks for the replies!

I should have mentioned that i am using Ubuntu 22.04.02. A bit embarrassing but: I can't find the Salome Python Interpreter.
I wanted to set the enviroment manually like mentioned however it is difficult to pin down the needed file.
Hr_kules is offline   Reply With Quote

Old   June 20, 2023, 09:10
Default Solution
  #5
Senior Member
 
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6
Hr_kules is on a distinguished road
Just in case somebody in the future stumbles upon the same problem. To run the Python API in vscode you navigate with the terminal to your salome folder. There is a bash script called env_launch.sh. Run the following command:
Code:
source env_launch.sh
Then start vscode with
Code:
code
The API works and you get to work!
AtoHM likes this.
Hr_kules is offline   Reply With Quote

Old   October 11, 2024, 17:08
Default
  #6
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 151
Rep Power: 10
Marpole is on a distinguished road
In Ubuntu, the following command should work.
Code:
./salome -t yourApp.py
__________________
Charles L.
Marpole is offline   Reply With Quote

Reply

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
[PyFoam] Using pyFoamPlotWatcher.py To Plot Residuals m_ridzon OpenFOAM Community Contributions 22 January 26, 2021 19:48
OpenFOAM extended 4.0 Error with Multinode Set-up Liweix OpenFOAM Running, Solving & CFD 1 February 18, 2020 01:50
python script to create geometry for salome, and then mesh 6863523 Mesh Generation & Pre-Processing 4 March 18, 2017 10:00
[OpenFOAM] Paraview python API? me3840 ParaView 0 January 23, 2016 21:17
[General] VTK API: Working with values inside the python shell Thoma ParaView 4 January 10, 2013 15:35


All times are GMT -4. The time now is 00:03.