Personal tools
You are here: Home Forum Use Importing h5py on Salome TUI

Importing h5py on Salome TUI

Up to Use

Importing h5py on Salome TUI

Posted by Moise Rousseau at March 05. 2019

Hi everyone,

I am using Salome as a pre-processor and mesh generator for a subsurface flow simulation named PFLOTRAN (www.pflotran.org). I am writing a Python plugins to export automatically Salome meshes to the right format needed. To do so, I need to create HDF5 file and I would like to use the h5py module.

Unfortunately, I was unable to import the h5py module. I try "import h5py" on the TUI but it return me an "ImportError: No module named 'h5py'". If I try to import the module under a terminal on my computer, it work fine.

Thus, I had to the sys.path list the path to the h5py installation folder ('/home/moise/.local/lib/python3.6/site-packages'), and it seem to find the module. But I got the following error when importing on Salome :

Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/moise/.local/lib/python3.6/site-packages/h5py/__init__.py", line 26, in <module> from . import _errors ImportError: cannot import name '_errors'

I googled this error and it seems to happen when we try to import the module from the install directory : https://stackoverflow.com/questions/36375691/python-jupyter-cannot-import-name-errors-for-h5py

A similar error have been answered here : https://www.salome-platform.org/forum/forum_10/7381901#445101050

Thus, I would like to know if there is an easy way to import the h5py module easily. Can you help me to do so ? If not, how can I bypass this error ? I know I could first export the mesh as DAT and after run the script from my terminal, but I would like Salome to do it automatically.

I am running Salome 9.2.0 on Ubuntu 18.04.

 

Thanks in advance for your help !

M. Rousseau

 

p, li { white-space: pre-wrap; }

Re: Importing h5py on Salome TUI

Posted by Nabil Ghodbane at March 05. 2019

Hi,

you need to install PIP beforehand. Try this solution which was suggested to me:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

SALOME-9.2.0-UB18.04-SRC/salome context

python ./get-pip.py

SALOME-9.2.0-UB18.04-SRC/INSTALL/Python/bin/pip  install h5py

If any issue, let us know.

Re: Importing h5py on Salome TUI

Posted by Moise Rousseau at March 05. 2019

Hi !

Thanks for your help.

I get successfully the get-pip.py script. Unfortunately, I don't know what you want me do to with the "SALOME-9.2.0-UB18.04-SRC/salome context" command. Moreover, when I launch the script "get-pip.py" using the command "exec(open('get-pip.py ').read())" on Salome TUI, it crash without an error message and pip is not installed (i.e. I couldn't import pip on Salome TUI, but I still get pip on my computer running in a terminal). Thus I couln't install h5py for using it on Salome TUI.

Do you actually run h5py on Salome ? Do you experience the same issue ?

Moise

Re: Importing h5py on Salome TUI

Posted by Nabil Ghodbane at March 05. 2019

Hi

the command:

SALOME-9.2.0-UB18.04-SRC/salome context

is aimed to setup your environment such that you point to the Python shipped with SALOME.

 

So just to make sure I understand, can you confirm that you did:

    - start a console (e.g. konsole or xterm)

    -  download get-pip.py: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

   

    - cd to the folder where you unpacked the SALOME-9.2.0-UB18.04-SRC archive (you wrote you use Ubuntu 18.04 archive)

    - execute: SALOME-9.2.0-UB18.04-SRC/salome context

    - execute: python get-pip.py

    - install pip by executing: SALOME-9.2.0-UB18.04-SRC/INSTALL/Python/bin/pip  install h5py

 

 

 

did you do that ?

Re: Importing h5py on Salome TUI

Posted by Moise Rousseau at March 06. 2019

Hi,

I understand better, thank you !

I have download get-pip.py and succesfully setup the Salome environment using SALOME-9.2.0-UB18.04-SRC/salome context.

I got trouble when executing the script "get-pip.py". I got the following error :

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Collecting pip

  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/

  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/

  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/

  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/

  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/

  Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

  Could not find a version that satisfies the requirement pip (from versions: ) No matching distribution found for pip

I try to install PyOpenSSL (https://pypi.org/project/pyOpenSSL/), but it require dependencies, and these dependencies require others dependencies and so on that I need to install manually.

Do you experience the same issue ? Do you have a trick or I should install all dependencies manually ?

Thank again for your help,

Moise

Re: Importing h5py on Salome TUI

Posted by Nabil Ghodbane at March 13. 2019

Hi,

unfortunately the Ubuntu 18 python version misses the ssl module (you can check this by doing import ssl)

Other archives like e.g. Ubuntu 16 or CentOS 7.5 do have pip installed which allows you to install h5py.

 

 

Re: Importing h5py on Salome TUI

Posted by Moise Rousseau at Monday 22:54

Hi Nabil,

Thanks for your help. With it, I manage to successfully install h5py. If you or other person want to do the same, follow the next step :

1. Download the pip and pkgconfig wheel, and h5py source on the following address:

https://pypi.org/project/pip/

https://pypi.org/project/pkgconfig/

https://pypi.org/project/h5py/

2. Copy these new files in the Salome binaries folder

3. Open a terminal in Salome binaries folder and load the salome context with the following command:

./salome context

4. Go (cd command) to the binaries folder:
cd BINARIES-UB18.04/
5. With the pip wheel, install first pkgconfig package and after h5py source (command may change according to the version you want to install):
python pip-19.0.3-py2.py3-none-any.whl/pip install pkgconfig-1.4.0-py2.py3-none-any.whl
python pip-19.0.3-py2.py3-none-any.whl/pip install h5py-2.9.0.tar.gz
6. End. You can check the installation by launching Salome and write the following command in Salome TUI :
import h5py
 
Thanks you again for your help,
Moise

Re: Importing h5py on Salome TUI

Posted by Nabil Ghodbane at Tuesday 11:46

Hi Moise,

glad to see that you found a workaround to install pip. FYI, this issue is fixed in the next release.

nabil

Powered by Ploneboard
Document Actions