无法正确安装obspy

时间:2016-10-09 13:08:01

标签: python installation anaconda

可能是安装了obspy,但我错过了某个安装过程或某个其他问题。但无论如何我按照link按照说明进行操作,因为我已经安装了anacondas,所以我使用了:

sudo port install py27-obspy

sudo port select python python27

然后完成...

pip install obspy

然后,当运行基本python脚本以测试obspy库时,我收到导入错误:

ImportError: No module named obspy.imaging.mopad_wrapper

我尝试在我的python shell中导入库,它提供了这个输出:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/__init__.py", line 40, in <module>
    from obspy.core.utcdatetime import UTCDateTime  # NOQA
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/__init__.py", line 119, in <module>
    from obspy.core.utcdatetime import UTCDateTime
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/utcdatetime.py", line 20, in <module>
    from obspy.core.util.decorator import deprecated
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/__init__.py", line 41, in <module>
    from obspy.core.util.testing import add_doctests, add_unittests
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/obspy/core/util/testing.py", line 28, in <module>
    from lxml import etree
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/etree.so, 2): Library not loaded: libxml2.2.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/etree.so
  Reason: Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

是否有人尝试过安装obspy库?如果是这样,您是否遇到过任何问题?

1 个答案:

答案 0 :(得分:1)

如果您使用的是anaconda,则需要使用obspy

安装conda install

conda install --channel https://conda.anaconda.org/obspy obspy

<强> TL; DR

由于它不在默认存储库中,因此您需要使用搜索功能来查找它:

anaconda search -t conda obspy

找到所有相关的包。对于obspy,搜索会返回:

Using Anaconda Cloud api site https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
     Name                      |  Version | Package Types   | Platforms
     ------------------------- |   ------ | --------------- | ---------------
     auto/obspydmt             |    0.4.0 | conda           | linux-64
                                          : https://github.com/kasra-hosseini/obspyDMT
     conda-forge/obspy         |    1.0.2 | conda           | linux-64, win-32, win-64, osx-64
     krisvanneste/obspy        |    0.9.2 | conda           | win-64
     mbyt/obspy                |   0.10.0 | conda           | linux-64
     obspy/obspy               |    1.0.2 | conda, pypi     | linux-64, win-32, win-64, linux-32, osx-64
                                          : ObsPy: A Python Toolbox for seismology/seismological observatories.
Found 5 packages

然后,它会指示您使用anaconda show obspy/obspy获取有关该软件包的更多信息,该信息还提供了安装说明。

Using Anaconda Cloud api site https://api.anaconda.org
Name:    obspy
Summary: ObsPy: A Python Toolbox for seismology/seismological observatories.
Access:  public
Package Types:  conda, pypi
Versions:
   + 0.10.0rc1
   + 0.10.0
   + 0.0.0+archive
   + 0.10.1rc1
   + 0.10.1rc2
   + 0.10.1
   + 0.10.2
   + 1.0.0
   + 1.0.1
   + 1.0.2

To install this package with conda run:
     conda install --channel https://conda.anaconda.org/obspy obspy
To install this package with pypi run:
     pip install -i https://pypi.anaconda.org/obspy/simple obspy