关于numpy的版本报错解决方法

2019-01-09  本文已影响98人  Nickier

---------------

Nickier

2019-01-09

---------------

在运行一下命令时,出现了一个问题

bamCoverage -b ../mapping/KM02O_bqsr.bam -o ./KM02O_bqsr.bw

报错信息

RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
Traceback (most recent call last):
  File "/home/hcguo/miniconda3/envs/wes/bin/bamCoverage", line 5, in <module>
    from deeptools.bamCoverage import main
  File "/home/hcguo/miniconda3/envs/wes/lib/python2.7/site-packages/deeptools/bamCoverage.py", line 8, in <module>
    from deeptools import writeBedGraph  # This should be made directly into a bigWig
  File "/home/hcguo/miniconda3/envs/wes/lib/python2.7/site-packages/deeptools/writeBedGraph.py", line 5, in <module>
    import pyBigWig
ImportError: numpy.core.multiarray failed to import

一开始没有仔细阅读,直接复制了最后一行就去google查了一下,如有说要把版本降级的https://zhuanlan.zhihu.com/p/29026597
然而查到的信息试了又试,但还是没有解决。
回头仔细看报错信息,提到了numpy的版本号不对

RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb

在这里,依赖的是0xc而我的是0xb
然后我就用下面命令查了一下我的numpy文件的版本

pip show numpy

发现版本号是

$pip show numpy
Name: numpy
Version: 1.13.1
Summary: NumPy: array processing for numbers, strings, records, and objects.
Home-page: http://www.numpy.org
Author: NumPy Developers
Author-email: numpy-discussion@python.org
License: BSD
Location: /home/hcguo/miniconda3/envs/wes/lib/python2.7/site-packages
Requires: 
Required-by: pandas, matplotlib, deepTools

然后我再去查了一下0xc对应的是什么版本?在下面这个链接里,有提到了0xc对应的版本解决方法:
https://github.com/enigmampc/catalyst/issues/106

I have met the same problem with you:
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
And I solved it by upgrading my numpy to 1.14.1
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb

于是我把numpy的版本号更新为1.14.1

pip install -U numpy==1.14.1

完美解决问题~
注意:如果以后其他命令依赖的numpy版本号不是1.14.1,则需要再改一次。而关于numpy版本的报错,只需要知道依赖的版本号是多少,然后将自己的版本号修改为所依赖的版本号即可。

上一篇下一篇

猜你喜欢

热点阅读