【问题标题】:ImportError: No module named bitarrayImportError:没有名为 bitarray 的模块
【发布时间】:2015-07-04 15:18:13
【问题描述】:

我正在尝试在 Python 中实现模糊 c 均值算法。我在 Matlab 中使用了内置函数来做同样的事情。我想知道 Python 中是否也有这样简单的方法。我试过了

http://peach.googlecode.com/hg/doc/build/html/tutorial/fuzzy-c-means.html

我已经试过了:

from numpy import *
import peach as p

    x = array( [
        [ 0., 0. ], [ 0., 1. ], [ 0., 2. ], [ 1., 0. ], [ 1., 1. ], [ 1., 2. ],
        [ 2., 0. ], [ 2., 1. ], [ 2., 2. ], [ 5., 5. ], [ 5., 6. ], [ 5., 7. ],
        [ 6., 5. ], [ 6., 6. ], [ 6., 7. ], [ 7., 5. ], [ 7., 6. ], [ 7., 7. ] ] )

    mu = array( [
        [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ],
        [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.3, 0.7 ],
        [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ],
        [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ] ] )


    m = 2.0

    fcm = p.FuzzyCMeans(x, mu, m)

    print "After 20 iterations, the algorithm converged to the centers:"
    print fcm(emax=0)
    print "The membership values for the examples are given below:"
    print fcm.mu

但得到 * ImportError: No module named bitarray *

谁能帮忙?

【问题讨论】:

  • 请发布您的代码。
  • 您尝试安装了吗?
  • @Kishore 我已经编辑了我的帖子。请通过
  • @IgnacioVazquez-Abrams 是的,我尝试安装 bitarray-0.8.1,但似乎安装不正确..我使用的是 windows 8 32 位。
  • 启动一个 python 控制台并检查这是否 - from bitarray import bitarray 有效。如果您收到importError,请检查 python dist-packages 目录是否存在该模块。

标签: python-2.7 fuzzy-c-means


【解决方案1】:

有时只是因为你在包的安装文件夹中,所以你无法导入它。尝试转到其他地方并重新运行它。

【讨论】:

    【解决方案2】:

    我遇到了这个问题。做pip install bitarray时忘记了sudo

    【讨论】:

      猜你喜欢
      • 2013-03-11
      • 2012-12-07
      • 2012-05-23
      • 2019-07-29
      • 2014-03-15
      • 2017-12-29
      • 2014-09-12
      • 2017-05-09
      • 2013-06-04
      相关资源
      最近更新 更多