save data in hdf5 file

Asked by Jinny Kim

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:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
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

Revision history for this message
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..

Revision history for this message
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

Revision history for this message
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

Revision history for this message
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

Revision history for this message
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.......

Revision history for this message
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

Revision history for this message
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?

Revision history for this message
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'..

Revision history for this message
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..

Revision history for this message
Launchpad Janitor (janitor) said :
#11

This question was expired because it remained in the 'Open' state without activity for the last 15 days.