save data in hdf5 file

Asked by Jinny Kim on 2019-09-08

Hello all,

I want to save particle data in hdf5file. In order to do this, I need to import 'h5py' module. I think I need to add 'h5py'module in Yade library, is it possible?

Thank you for your help in advance.

Jinny Kim.

Question information

Language:
English Edit question
Status:
Open
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2019-09-09
Last reply:
2019-09-09
Jan Stránský (honzik) said : #1

Hi,

> In order to do this, I need to import 'h5py' module.

yes. it should be no problem (or?)

> I think I need to add 'h5py'module in Yade library, is it possible?

just use h5py in your python script
(not sure what you mean by library)

cheers
Jan

Jinny Kim (jinnyk) said : #2

I tried that, but I got this error: ImportError: No module name h5py. When I run the python script, I am using this command in terminal: yade filename.py..

Jan Stránský (honzik) said : #3

Have you installed h5py to your computer?
If yes, how?
If no, what version of yade you use?

Jan

Jinny Kim (jinnyk) said : #4

Yes, I have installed it. I installed it with Miniconda by following [1].
[1] http://docs.h5py.org/en/stable/quick.html

Jan Stránský (honzik) said : #5

Could be python 2/3 problem.

What does Yade says if you type
import sys; sys.version
?

what is the output of command line commands
python -c "import h5py"
python3 -c "import h5py"
?

thanks
Jan

Jinny Kim (jinnyk) said : #6

What does Yade says if you type
import sys; sys.version
?
> '2.7.12 (default, Nov 12 2018, 14:36:49) \n[GCC 5.4.0 20160609]'

what is the output of command line commands
python -c "import h5py"
python3 -c "import h5py"
?
> If i try those commands in the terminal, there is no any output.......

Jan Stránský (honzik) said : #7

> If i try those commands in the terminal, there is no any output.......

it means everything is ok and h5py is available for both python 2 and 3.
For some reason, the installation with miniconda (don't know it) is not visible for Yade. You can try:

a) point python to the actual installation in your script:
import sys
sys.path.append("/path/where/h5py/was/installed")
import h5py

b) use pip
pip install h5py --user
(or without --user, then you would need sudo)

c) use apt
sudo apt install python-h5py

cheers
Jan

Jinny Kim (jinnyk) said : #8

Thank you so much for your help. Can I ask a simple question? how to find the path where h5py was installed?

Jinny Kim (jinnyk) said : #9

I am trying (a) in your reply. I found the path of the module like this:
import sys
sys.modules['h5py']

Then, I tried (a) by using the path that I got above. but tase said 'no module named h5py'..

Jinny Kim (jinnyk) said : #10

Okay, I think I found the problem. when I try this command (python2 -c "import h5py"), it says that 'no module named h5py. I think h5py is no available for python2..

Can you help with this problem?

Provide an answer of your own, or ask Jinny Kim for more information if necessary.

To post a message you must log in.