|
[Sponsors] |
June 5, 2023, 08:37 |
Salome python api
|
#1 |
Senior Member
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6 |
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? |
|
June 5, 2023, 14:16 |
|
#2 |
Senior Member
M
Join Date: Dec 2017
Posts: 698
Rep Power: 12 |
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. |
|
June 5, 2023, 14:38 |
|
#3 |
Senior Member
Niels Nielsen
Join Date: Mar 2009
Location: NJ - Denmark
Posts: 556
Rep Power: 27 |
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.
__________________
Linnemann PS. I do not do personal support, so please post in the forums. |
|
June 6, 2023, 08:06 |
|
#4 |
Senior Member
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6 |
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. |
|
June 20, 2023, 09:10 |
Solution
|
#5 |
Senior Member
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6 |
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 Code:
code |
|
October 11, 2024, 17:08 |
|
#6 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 151
Rep Power: 10 |
In Ubuntu, the following command should work.
Code:
./salome -t yourApp.py
__________________
Charles L. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |