在Windows中为Python安装libsvm
我尝试从这里下载并安装libsvm,链接是http://www.csie.ntu.edu.tw/~cjlin/libsvm/。我已经按照README里写的步骤操作了。
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 个回答
1
简单的安装方法:
从这个链接下载 libsvm 的安装文件:http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsvm。你可以根据你的 Windows 系统配置选择安装 libsvm‑3.17.win‑amd64‑py2.7.exe
或 libsvm‑3.17.win32‑py2.7.exe
。