从sklearn导入CountVectorizer时出错

时间:2015-07-03 00:54:14

标签: python numpy scipy scikit-learn pycharm

当我尝试以下导入语句时

from sklearn.feature_extraction.text import CountVectorizer

我收到以下错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\sklearn\feature_extraction\__init__.py", line 7, in <module>
    from .dict_vectorizer import DictVectorizer
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\sklearn\feature_extraction\dict_vectorizer.py", line 15, in <module>
    from ..utils import check_array, tosequence
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\sklearn\utils\__init__.py", line 16, in <module>
    from .class_weight import compute_class_weight, compute_sample_weight
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\sklearn\utils\class_weight.py", line 7, in <module>
    from ..utils.fixes import in1d
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\sklearn\utils\fixes.py", line 318, in <module>
    from scipy.sparse.linalg import lsqr as sparse_lsqr
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\scipy\sparse\linalg\__init__.py", line 109, in <module>
    from .isolve import *
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
    from .iterative import *
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Python27\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
    from . import _iterative
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: The specified module could not be found.

我目前正在使用Windows 8 64位,PyCharm 4.5.1和Python 2.7.1(64位),并且已经安装了scikit-learn 0.16.1及其依赖项(Numpy 1.9.2和0.15.1)如Scikit Installation guide)中所列:

  • Python(&gt; = 2.6或&gt; = 3.3)
  • NumPy(&gt; = 1.6.1)
  • SciPy(&gt; = 0.9)

1 个答案:

答案 0 :(得分:0)

也许尝试使用Anaconda?我认为这是比较流行的scipy发行版之一,它非常稳定。另外,请确保使用pip或其他软件包管理器来安装软件包。