ImportError: No module named _ckernel

8 篇文章 0 订阅
6 篇文章 0 订阅

安装pyml后,import PyML出错:

>>> import PyML
>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "PyML/__init__.py", line 4, in <module>
    from PyML.containers import *
  File "PyML/containers/__init__.py", line 3, in <module>
    VectorDataSet = __import__('PyML.containers.vectorDatasets', fromlist=['']).VectorDataSet
  File "PyML/containers/vectorDatasets.py", line 5, in <module>
    from PyML.containers.baseDatasets import WrapperDataSet, BaseVectorDataSet
  File "PyML/containers/baseDatasets.py", line 4, in <module>
    from PyML.containers import ker
  File "PyML/containers/ker.py", line 6, in <module>
    from ext import ckernel
  File "PyML/containers/ext/ckernel.py", line 25, in <module>
    _ckernel = swig_import_helper()
  File "PyML/containers/ext/ckernel.py", line 17, in swig_import_helper
    import _ckernel
    ImportError: No module named _ckernel

最后发现是在 pyml 安装包解压缩目录下运行的原因,因为 PyML/ 目录下已经有一个init.py,Python把这个目录当成了一个库,所以当想要 import PyML 的时候,Python就会在这个解压缩目录里面找,不是想要使用的那个 PyML库.
解决办法:进去其他任意目录,重新运行即可。
例如:

#cd /
# python

Python 2.7.5 (default, Aug  4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyML
>>> PyML.__version__
'0.7.14'

参考 https://sourceforge.net/p/pyml/discussion/393034/thread/0ae37eac/

You probably tried to import the PyML module while in the directory created after extracting the tar.gz. That directory has a

PyML/
directory with a file called

__init__.py
in it. The existence of that file make that directory a Python module. So, when you tried to import the PyML module, Python found it there, and that module wasn't the one you wanted.

The "solution" is to

cd
into some other directory and try the import again.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值