import pyhdf.HDF, ImportError: No module named '_hdfext'
fzhu2e opened this issue · comments
Hi there,
My system is OSX and Python version is Python3.
I installed hdf4 library by homebrew, and I set the environment as:
export INCLUDE_DIRS=/usr/local//include
export LIBRARY_DIRS=/usr/local/lib
since homebrew installs files under /usr/local
.
Also, I can successfully install pyhdf by:
$ python3 setup.py install
running install
running bdist_egg
running egg_info
running build_src
build_src
building extension "pyhdf._hdfext" sources
build_src: building npy-pkg config files
writing python_hdf4.egg-info/PKG-INFO
writing dependency_links to python_hdf4.egg-info/dependency_links.txt
writing top-level names to python_hdf4.egg-info/top_level.txt
reading manifest file 'python_hdf4.egg-info/SOURCES.txt'
writing manifest file 'python_hdf4.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
creating build/bdist.macosx-10.5-x86_64/egg
creating build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/__init__.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/_hdfext.so -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/error.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/HC.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/HDF.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/hdfext.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/SD.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/six.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/test_SD.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/V.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
copying build/lib.macosx-10.5-x86_64-3.4/pyhdf/VS.py -> build/bdist.macosx-10.5-x86_64/egg/pyhdf
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/__init__.py to __init__.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/error.py to error.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/HC.py to HC.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/HDF.py to HDF.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/hdfext.py to hdfext.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/SD.py to SD.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/six.py to six.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/test_SD.py to test_SD.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/V.py to V.cpython-34.pyc
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/VS.py to VS.cpython-34.pyc
creating stub loader for pyhdf/_hdfext.so
byte-compiling build/bdist.macosx-10.5-x86_64/egg/pyhdf/_hdfext.py to _hdfext.cpython-34.pyc
creating build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying python_hdf4.egg-info/PKG-INFO -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying python_hdf4.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying python_hdf4.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying python_hdf4.egg-info/top_level.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying python_hdf4.egg-info/zip-safe -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.5-x86_64/egg/EGG-INFO/native_libs.txt
creating 'dist/python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg' and adding 'build/bdist.macosx-10.5-x86_64/egg' to it
removing 'build/bdist.macosx-10.5-x86_64/egg' (and everything under it)
Processing python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg
Removing /Users/Lyric/Tools/Python3/lib/python3.4/site-packages/python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg
Copying python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg to /Users/Lyric/Tools/Python3/lib/python3.4/site-packages
python-hdf4 0.9 is already the active version in easy-install.pth
Installed /Users/Lyric/Tools/Python3/lib/python3.4/site-packages/python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg
Processing dependencies for python-hdf4==0.9
Finished processing dependencies for python-hdf4==0.9
I can import pyhdf
. However, when I import pyhdf.HDF
, it raises error:
import pyhdf.HDF
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-c2e4930f14c5> in <module>()
----> 1 import pyhdf.HDF
/Users/Lyric/Tools/Python3/lib/python3.4/site-packages/python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg/pyhdf/HDF.py in <module>()
72 import os, sys, types
73
---> 74 from . import hdfext as _C
75 from .six.moves import xrange
76 from .HC import HC
/Users/Lyric/Tools/Python3/lib/python3.4/site-packages/python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg/pyhdf/hdfext.py in <module>()
26 fp.close()
27 return _mod
---> 28 _hdfext = swig_import_helper()
29 del swig_import_helper
30 else:
/Users/Lyric/Tools/Python3/lib/python3.4/site-packages/python_hdf4-0.9-py3.4-macosx-10.5-x86_64.egg/pyhdf/hdfext.py in swig_import_helper()
18 fp, pathname, description = imp.find_module('_hdfext', [dirname(__file__)])
19 except ImportError:
---> 20 import _hdfext
21 return _hdfext
22 if fp is not None:
ImportError: No module named '_hdfext'
Should I need to compile all the libraries (zlib, libjpeg, hdf4) by myself?
Should I need to compile all the libraries (zlib, libjpeg, hdf4) by myself?
No, you don't need to compile them.
You should look inside /Users/Lyric/Tools/Python3/lib/python3.4/site-packages/ and check _hdfext.so is linked against all the required libraries. You can use something equivalent to Linux ldd command (otool -L ?) to check. I don't have an OS X system, so it's hard for me to reproduce this problem.
Thanks. I copied the _hdfext.so
file to the site-packages directory manually and it works now. So it turns out that the .so
file was not copied to the directory automatically.
Thank you!
I had a similar issue. I used ldd
as suggested above (thank you!) and found that libjpeg.so.8 was not present. I then checked the version of jpeg, and the version that had been installed was version 9, so libjpeg.so.9 was present. So I uninstalled jpeg
, which removes hdf4
and python-hdf4
. Then I ran 'conda install jpeg=8', and then conda install -c hcc python-hdf4
. This way the links were correctly set and my problem was solved.
So it seems like running conda install -c hcc python-hdf4
does not correctly check and/or install the correct version of jpeg.
error: Command "gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/Daradorn/.local/include -fPIC -I/home/appl/usr/local/lib/python2.7/site-packages/numpy/core/include -I/home/appl/usr/local/include/python2.7 -c pyhdf/hdfext_wrap.c -o build/temp.linux-x86_64-2.7/pyhdf/hdfext_wrap.o" failed with exit status 1
How to deal with pyhdf-0.8.3? I complete with all (ZILB, SZIP and JPEG)
Is there a better fix for this? Im currently getting my error too and no amount of uninstalling/reinstalling seems to be fixing it.
@AlysonR Use conda so you don't have to worry about these issues. See top of installation guide: http://fhs.github.io/pyhdf/install.html
I installed using conda install -c conda-forge pyhdf
and still got the _No module named 'hdfext' error.
Hello,Could you share the _hdftext.so to me? Or tell me how to find it, please?
Thanks. I copied the file to the site-packages directory manually and it works now. So it turns out that the file was not copied to the directory automatically.
_hdfext.so``.so
Thank you!
Hello my friend,I have the same problem, Could you please share the _hdftext.so to me? or tell me how to download it, please?
Thanks. I copied the file to the site-packages directory manually and it works now. So it turns out that the file was not copied to the directory automatically.
_hdfext.so
.so ``
Thank you!Hello my friend,I have the same problem, Could you please share the _hdftext.so to me? or tell me how to download it, please?
Hello, friend. Have you resolved your issue? I encountered the same problem as you did.