【问题标题】:h5py gives error after installation [duplicate]h5py在安装后给出错误[重复]
【发布时间】:2012-04-10 00:48:06
【问题描述】:

可能重复:
Installing h5py on OS X

我正在尝试让 h5py 在我的 OS X Lion 10.7.3 Macbook Pro 上运行。它以前工作过,但不知何故被卸载了,我无法再次安装它。似乎与安装 XCode 4.3 有关,但我不确定。

导入h5py时出现如下错误:

>>> import h5py


   Traceback (most recent call last):

  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/h5py/__init__.py", line 1, in <module>
    from h5py import _errors
ImportError: dlopen(/Library/Python/2.7/site-packages/h5py/_errors.so, 2): Symbol not found: _H5E_ALREADYEXISTS_g
  Referenced from: /Library/Python/2.7/site-packages/h5py/_errors.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/h5py/_errors.so

我猜这与 HDF5 库有关。它还没有安装,所以我先用它安装了它

brew install hdf5

这没有出错。但最后会出现以下警告。我想这很重要:

ld: warning: ignoring file ../hdf5-1.8.8/hdf5/lib/libhdf5.a, 
file was built for archive which is not the architecture being linked (i386)

我不是 100% 确定这意味着什么,但我猜这个库是为 i386 架构编译的,但是在这个目录中有更多文件并没有抱怨:

libhdf5.la
libhdf5.dylib -> libhdf5.7.dylib
libhdf5.7.dylib
libhdf5.settings
libhdf5.a
libhdf5_hl.la
libhdf5_hl.dylib -> libhdf5_hl.7.dylib
libhdf5_hl.a
libhdf5_hl.7.dylib

后来我自己也编译了源码,从 HDF5 群网站 (http://www.hdfgroup.org/HDF5/) 下载。使用以下配置行,以确保它创建共享库,我添加了 --enable-shared 并禁用了 fortran:

./configure --with-zlib=/usr/local --disable-fortran 
--prefix=/usr/local/ --target=x86_64-apple-darwin 
-build=x86_64-apple-darwin --host=x86_64-apple-darwin 
--enable-shared --disable-production

我已经删除了 h5py 和 hdf5 库并重新安装了几次(都自己编译 h5py,如使用 pip 和 easy_install),但这似乎没有帮助。

我还使用我刚刚使用此命令创建的构建安装了 h5py:

python setup.py build --hdf5=../hdf5-1.8.8/hdf5

我还将我的 numpy 和 scipy 安装更新到了最新版本。

【问题讨论】:

    标签: python compilation hdf5 h5py


    【解决方案1】:

    从全新安装的 Mac OS X Lion 开始,我需要做的是:

    • 使用命令行工具安装 Xcode
    • 安装 Homebrew
    • 告诉 Homebrew Xcode 在哪里 (xcode-select ...)

    那么我可以:

    $ brew install hdf5
    

    链接不正确,因为我的/usr/local/lib 不可写。检查brew doctor,看看是否有任何未链接的包:

    $ brew doctor
    Warning: You have unlinked kegs in your Cellar
    Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
    those kegs to fail to run properly once built.
    
        hdf5
        szip
    

    所以我使目录可写并使用

    $ brew link hdf5
    $ brew link szip
    

    那我就可以了

    $ sudo pip install h5py
    

    然后很快。

    >>> import h5py
    >>> 
    

    【讨论】:

      猜你喜欢
      • 2015-10-19
      • 2018-07-22
      • 2020-05-23
      • 2018-06-17
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      相关资源
      最近更新 更多