在windows中为python安装libsvm

时间:2014-03-04 07:33:23

标签: python svm

我尝试安装从这里下载的libsvm http://www.csie.ntu.edu.tw/~cjlin/libsvm/ 我已经在自述文件中写了

Building Windows Binaries
=========================

Windows binaries are in the directory `windows'. To build them via
Visual C++, use the following steps:

1. Open a DOS command box (or Visual Studio Command Prompt) and change
to libsvm directory. If environment variables of VC++ have not been
set, type

"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"

You may have to modify the above command according which version of
VC++ or where it is installed.

2. Type

nmake -f Makefile.win clean all

3. (optional) To build shared library libsvm.dll, type

nmake -f Makefile.win lib

我还将libsvm.dll复制到我的windows32文件夹中。

我似乎无法找到任何错误,但当我编译了一个带有“import svm”的python代码时,我收到了以下错误:

$ python analyze.py
Traceback (most recent call last):
  File "analyze.py", line 2, in <module>
    import baseline_classifier, naive_bayes_classifier, max_entropy_classifier, libsvm_classifier
  File "D:\twitter-sentiment-analyzer-master\libsvm_classifier.py", line 1, in <module>
    import svm
ImportError: No module named svm

1 个答案:

答案 0 :(得分:1)

简便的安装方式:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsvm下载libsvm的安装二进制文件 您可能需要安装libsvm‑3.17.win‑amd64‑py2.7.exelibsvm‑3.17.win32‑py2.7.exe,具体取决于您的Windows配置