Personal tools
You are here: Home Forum Install & build Installing SMESH module as Python site-package

Installing SMESH module as Python site-package

Up to Install & build

Installing SMESH module as Python site-package

Posted by ewout at May 30. 2013

I am searching for a way to install only the SMESH module as a python site-package.

So i am able to create meshes in my python IDE. ( I am using spyder from www.pythonxy.com)

Where can i find the separate SMESH module and how do i install it?

Re: Installing SMESH module as Python site-package

Posted by Konyaro at March 23. 2019

Hello,

This is an old post but I'm very interesting in using the Salome environment in an Ipython console, ideally within Spyder.

1) This posts says to add packages but it does't seem to work:

 

2) I tried to add the following in the Spyder's startup lines:

Import os, os.system(r'… work\set_env.bat'), os.system(r'… products\env_launch.bat')

 

3) I tried to change the python interpreter to …\SALOME-9.2.2\PRODUCTS\python-3.6.0\python.exe

I get the following error: (ModuleNotFoundError: No module named 'spyder_kernels')

 

I'm using the Windows version.

 

Any tips are welcome,

 

Konyaro

Re: Installing SMESH module as Python site-package

Posted by Nabil Ghodbane at March 25. 2019

Hi,

could you try to do it the other way around: source the two scripts and start spyder and let us know if it works

call <installdir>\work\set_env.bat

call <installdir>\products\env_launch.bat

start spyder

 

Re: Installing SMESH module as Python site-package

Posted by Konyaro at March 25. 2019

Hello Nabil,

Thank you for your help. I progressed a little bit.

1) I copied all the necessary libraries to ..\PRODUCTS\python-3.6.0\Lib\site-packages in order to be able to launch Spyder.

2) I copied the os.environ["PYTHONPATH"] from Salome to my script in Spyder. Then the same for os.environ["PATH"].

3) I added all paths:

for path in os.environ["PYTHONPATH"].split(";"):

    sys.path.append(path)

 

I am then able to import the Salome libraries. I get the following error when entering:

geompy = geomBuilder.New()

--> NameError: name 'lcc' is not defined

 

I need to investigate…

 

Konyaro

Re: Installing SMESH module as Python site-package

Posted by Mattia at March 26. 2019

Hi Konyaro,

as Nabil said, you should source the two batch files in your python script. Beside adding paths, they call other scripts (like prepare_modules.py) that will source other files from GEOM, SMESH, etc etc modules.

You may try to source them with exec() this way I think you won't need to add all modules manually into python packages folder.

I have not tried yet so maybe I'm wrong. It just makes sense to me.

Bye

Re: Installing SMESH module as Python site-package

Posted by Nabil Ghodbane at March 26. 2019

just a precision:

you should source the two batch files in your python script.

should read:

   start a dos terminal (cmd) and in that terminal:

    source the two batch scripts

   run spyder command in that terminal

 

Re: Installing SMESH module as Python site-package

Posted by Konyaro at March 27. 2019

Thank you Mattia and Nabil for your help,

I tried to source the two batch scripts from a dos terminal before launching Spyder or a

Python console.

Some paths are added indeed to the PATH and PYTHONPATH but some paths are still missing.

I then found out that I must add the modules I want to load in the set_env.bat:

SET env_m_list=(KERNEL, GUI, FIELDS, PARAVIS, GEOM, SMESH…)

I am then able to import some modules, for example: import GEOM. But I cannot add the Salome module: import salome.

The PATH and PYTHONPATH within Salome Python’s console contain many more paths. I guess they are added during Salome’s launch.

Do you have an idea how to add these paths?

Konyaro

Powered by Ploneboard
Document Actions