Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Astro Coke

[Python&Windows] HDF5 library version mismatched error 본문

Computer Setup

[Python&Windows] HDF5 library version mismatched error

astrodoo 2019. 4. 12. 22:55

시스템에 여러 버전의 HDF5 가 설치되어 있는 경우, 

python 에서 h5py를 사용할때 맨 아래와 같은 에러가 발생하는 경우가 있다.

 

이때, HDF5 가 다중 설치되어 있는 것이 anaconda 같은 환경내에서라면 

이 라이브러리를 지우고 다시 설치하면 문제가 해결될 것이다.

e.g.) 

> conda uninstall hdf5

> conda install hdf5

> conda install h5py

하지만, 이 문제가 anaconda 환경 밖에 설치된 hdf5와 충돌이 일어나는 것이라면,

문제의 포인트가 다르다. 

 

핵심 요인은 PATH환경변수의 우선순위!!!

 

h5py는 anaconda 내의 hdf5 라이브러리와 연동이 되어야 하기때문에,

python 사용시 anaconda의 path 가 다른 hdf5 path 보다 우선되어야 한다.

 

윈도우의 경우,

 

시작메뉴 검색에서 

Edit Environment Variables 를 입력하여 나오는 창에서

User variables 과 System variables 이 있는데,

 

이때 주의할 것은

System variables 이 우선된다는 것이다.

 

보통 anaconda 는 User variables 에 포함되어 있기 때문에,

이를 지우고, 같은 path 를 System variables 의 HDF5 path 보다 윗부분에 입력하면 된다.

 

이와 같은 설정에서 주의할 점이 있다.

 

이러한 설정 안에서 python의 h5py는 문제없이 작동하겠지만,

이젠 반대로 anaconda 밖에서 hdf5 라이브러리를 사용할 때 또 문제가 발생한다.

예컨대, Fortran 이나 c++ 프로그램 등에서 hdf5를 사용할 땐 (compiled by intel),

반대로 path를 다시 재조정 해주어야 한다.

 

이것은 간단히 executable file을 만들고,

e.g.) in ~/bin/load_hdf5_intel.sh

#!/bin/bash 

export PATH="/cygdrive/c/Program Files/HDF_Group/HDF5/1.10.5/bin:$PATH" 

이 후에 .bashrc 에 다음의 한줄만 추가하면 된다.

alias load_hdf5_intel='source ~/bin/load_hdf5_intel.sh' 

Shell script는 각각 독립적인 세션으로 작동하기 때문에 

> load_hdf5_intel.sh 

로 직접 입력하면 환경변수가 바뀐채로 남아있지 않는다. 그래서 alias 를 통해 source 로 실행하는 명령어를 만든 것이다. 

 

 

#################### 에러 메세지 ###########################

========================================================

>>> import h5py 
Warning! ***HDF5 library version mismatched error*** 
The HDF5 header files used to compile this application do not match 
the version used by the HDF5 library to which this application is linked. 
Data corruption or segmentation faults may occur if the application continues. 
This can happen when an application was compiled by one version of HDF5 but 
linked with a different version of static or shared HDF5 library. 
You should recompile the application or check your shared library related 
settings such as 'LD_LIBRARY_PATH'. 
You can, at your own risk, disable this warning by setting the environment 
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'. 
Setting it to 2 or higher will suppress the warning messages totally. 
Headers are 1.10.4, library is 1.10.5 
        SUMMARY OF THE HDF5 CONFIGURATION 
        ================================= 

General Information: 
------------------- 
                   HDF5 Version: 1.10.5 
                  Configured on: 2019-04-04 
                  Configured by: Visual Studio 15 2017 Win64 
                    Host system: Windows-10.0.17763 
              Uname information: Windows 
                       Byte sex: little-endian 
             Installation point: C:/Program 

Compiling Options: 
------------------ 
                     Build Mode: Release 
              Debugging Symbols: 
                        Asserts: 
                      Profiling: 
             Optimization Level: 

Linking Options: 
---------------- 
                      Libraries: 
  Statically Linked Executables: OFF 
                        LDFLAGS: /machine:x64 
                     H5_LDFLAGS: 
                     AM_LDFLAGS: 
                Extra libraries: 
                       Archiver: 
                         Ranlib: 

Languages: 
---------- 
                              C: yes 
                     C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe 19.16.27027.1 
                       CPPFLAGS: 
                    H5_CPPFLAGS: 
                    AM_CPPFLAGS: 
                         CFLAGS:  /DWIN32 /D_WINDOWS  /W3 
                      H5_CFLAGS: 
                      AM_CFLAGS: 
               Shared C Library: YES 
               Static C Library: YES 

                        Fortran: ON 
               Fortran Compiler: C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019/windows/bin/intel64/ifort.exe 19.0.0.20190206 
                  Fortran Flags: /W1 /nologo /fpp /libs:dll /threads 
               H5 Fortran Flags: 
               AM Fortran Flags: 
         Shared Fortran Library: YES 
         Static Fortran Library: YES 

                            C++: ON 
                   C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe 19.16.27027.1 
                      C++ Flags: /DWIN32 /D_WINDOWS /W3 /GR /EHsc 
                   H5 C++ Flags: 
                   AM C++ Flags: 
             Shared C++ Library: YES 
             Static C++ Library: YES 

                            JAVA: OFF 
                   JAVA Compiler: 

Features: 
--------- 
                   Parallel HDF5: OFF 
Parallel Filtered Dataset Writes: 
              Large Parallel I/O: 
              High-level library: ON 
                    Threadsafety: OFF 
             Default API mapping: v110 
  With deprecated public symbols: ON 
          I/O filters (external):  DEFLATE DECODE ENCODE 
                             MPE: 
                      Direct VFD: 
                         dmalloc: 
  Packages w/ extra debug output: 
                     API Tracing: OFF 
            Using memory checker: OFF 
 Memory allocation sanity checks: OFF 
          Function Stack Tracing: OFF 
       Strict File Format Checks: OFF 
    Optimization Instrumentation: