Debugging a salome script with a python IDE
This forum is DEPRECATED, please create new topics in the new SALOME forum.
For existing topics please transfer them to the new forum.
Hi
I am developing some salome python scripts and I it will be very helpful to run them through a python IDE, specially for debugging purposes. This user tried the same, but without success:
https://www.salome-platform.org/forum/forum_10/130992364
I tried setting a virtual enviroment from within a salome shell session, and also exporting LD_LIBRARY_PATH PYTHONPATH in the activate script. But when using it in the IDE (visual studio code), I get a "Naming Service Unreacheable" error which I cannot solve.
Is there any way to set this up correctly? Any other way to use an IDE to debug python salome code?
Thanks
The following suggested solution works for me. Surely one SALOME expert will suggest a more robust approach, but here is what you can do (tested on CentOS 7, not tried for other distributions)
- install code which is for instance installed in /usr/bin/code
- edit file SALOME-9.4.0-CO7-SRC/BINARIES-CO7/GUI/share/salome/plugins/gui/demo/salome_plugins.py
- in that file, search for runSalomeShellSession and replce:
if os.path.exists("/usr/bin/gnome-terminal"):
command = 'gnome-terminal -t "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
command = 'code'
elif os.path.exists("/usr/bin/gnome-terminal"):
command = 'gnome-terminal -t "SALOME %s - Shell session" -e "%s/salome shell" &'%(version,kernel_appli_dir)
- launch SALOME
- In the main menu bar, select Tools -> Plugins -> SALOME shell session
- this will launch code
- then you can run step by step your script
A cleaner approach. Download the enclosed file which:
- adds a function which launches Visual studio code.
- adds an entry : Tools -> Plugins -> Launch Visual Studio Code
You need to copy this file to:
SALOME-9.4.0-*-SRC/BINARIES-*/GUI/share/salome/plugins/gui/demo/salome_plugins.py
You need to ensure that you have Visual Studio Code installed.
This forum is DEPRECATED, please create new topics in the new SALOME forum.
For existing topics please transfer them to the new forum.