1

I have followed the instructions from http://hdfeos.org/software/pyhdf.php detailing how to install pyhdf and subsequently attempted to run the example code listed on this site (found here). Unfortunately, when I run the example code (which I saved as hdf.py) I get the following error message:

$python hdf.py
Traceback (most recent call last):
  File "hdf.py", line 28, in <module>
    from pyhdf.SD import SD, SDC
  File "/Users/kyleniezgoda/anaconda/lib/python2.7/site-packages/pyhdf-0.9.0-py2.7-macosx-10.5-x86_64.egg/pyhdf/SD.py", line 1004, in <module>
    from . import hdfext as _C
  File "/Users/kyleniezgoda/anaconda/lib/python2.7/site-packages/pyhdf-0.9.0-py2.7-macosx-10.5-x86_64.egg/pyhdf/hdfext.py", line 28, in <module>
    _hdfext = swig_import_helper()
  File "/Users/kyleniezgoda/anaconda/lib/python2.7/site-packages/pyhdf-0.9.0-py2.7-macosx-10.5-x86_64.egg/pyhdf/hdfext.py", line 24, in swig_import_helper
  _mod = imp.load_module('_hdfext', fp, pathname, description)
ImportError: dlopen(/Users/kyleniezgoda/anaconda/lib/python2.7/site-packages/pyhdf-0.9.0-py2.7-macosx-10.5-x86_64.egg/pyhdf/_hdfext.so, 2): Library not loaded: libjpeg.8.dylib
  Referenced from: /Users/kyleniezgoda/anaconda/lib/python2.7/site-packages/pyhdf-0.9.0-py2.7-macosx-10.5-x86_64.egg/pyhdf/_hdfext.so
  Reason: image not found

Anyone see something similar to this or have any suggestions? I am running on Mac OS 10.10.3 Yosemite, if that helps.

user2849910
  • 191
  • 1
  • 2
  • 6
  • Looks like the `libjpeg.8.dylib` library could not be found. Maybe [this](http://stackoverflow.com/questions/25187742/python-cannot-import-opencv-because-it-cant-find-libjpeg-8-dylib) helps? – jojonas Sep 09 '15 at 10:56
  • I viewed that page before posting this, and the suggestions did not work. 'libjpeg.8.dylib' is already in my /usr/local/lib/ which is part of my Python path, and so Python should not have a problem finding the file. – user2849910 Sep 10 '15 at 02:20

2 Answers2

1

I solved the same problem by upgrading numpy version. You can type following words in Anaconda Prompt:

pip install numpy --upgrade

and then import it again.

Pang
  • 9,564
  • 146
  • 81
  • 122
  • This worked for me. Python 3.8.2, pyhdf 0.10.5 and numpy 1.21.4. It upgraded to the same version of numpy but it still fixed the issue for me. Thanks! – M.O. Jun 14 '22 at 01:19
0

Install jpeg with this command in Anaconda prompt:

conda install -c conda-forge jpeg
double-beep
  • 5,031
  • 17
  • 33
  • 41