在python中导入numpy时,“ImportError:无法导入名称SkipTest”

时间:2016-06-28 07:13:07

标签: python numpy importerror

我在导入numpy时遇到问题。

请查看以下版本信息:

# cat /etc/redhat-release
CentOS release 6.5 (Final)

# python -V
Python 2.6.6

我已经使用pip安装了numpy(重新安装了几次)。

# pip install numpy

但是,当我尝试导入numpy时,它会显示如下错误:

# python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/usr/lib64/python2.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/lib64/python2.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/lib64/python2.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/lib64/python2.6/site-packages/numpy/core/__init__.py", line 58, in <module>
    from numpy.testing.nosetester import _numpy_tester
  File "/usr/lib64/python2.6/site-packages/numpy/testing/__init__.py", line 12, in <module>
    from . import decorators as dec
  File "/usr/lib64/python2.6/site-packages/numpy/testing/decorators.py", line 21, in <module>
    from .utils import SkipTest
ImportError: cannot import name SkipTest
>>>

我甚至尝试过“yum reinstall python”。 在所有情况下(numpy和python本身)安装成功完成。 但仍然有与上面相同的错误“ImportError:无法导入名称SkipTest”。

非常感谢任何变通解决方案。

谢谢, 奥贝德

2 个答案:

答案 0 :(得分:1)

似乎我必须升级我的python版本。 事实上,在安装python2.7之后,一切都很顺利。

我已经安装了python2.7,然后是numpy,如下所示:

yum install python27
scl enable python27 bash
pip2.7 install numpy

然后我可以使用python2.7 cli导入numpy。

谢谢, 奥贝德

答案 1 :(得分:1)

确实,较新的numpies不再支持python 2.6