0
votes

Does anybody know how to install h5py on datalab? pip install h5py doesn't work. apt-get install python-h5py is working in the shell but it doesn't recognize the package in datalab notebook!

Thnaks

2

2 Answers

2
votes

It is true that !pip install h5py wil allow you to install the library but unfortunately, even after a successful installation, the import will fail: enter image description here

The issue is rooted on an ongoing python-future issue ("surrogateescape handler broken when encountering UnicodeEncodeError") that is experienced in datalab because the underlying OS uses an 'ANSI_X3.4-1968' file system encoding.

As a hacky workaround, you may remove line 60 from h5py's __init__.py by running the following command from within a notebook cell:

!sed -i.bak '/run_tests/d' /usr/local/lib/python2.7/dist-packages/h5py/__init__.py
1
votes

Just make sure you run it using bash syntax: !pip install h5py in any notebook cell.