Instead of going through libsvm in order to access it with Python (I installed libsvm through MacPorts, and import svmutil fails), you might want to install the popular scikit-learn package, which contains an optimized version of libsvm with Python bindings.
The install is very simple with MacPorts: sudo port install py27-scikit-learn (adapt py27 to whatever version of Python you use).
Instead of going through libsvm in order to access it with Python (I installed libsvm through MacPorts, and import svmutil fails), you might want to install the popular scikit-learn package, which contains an optimized version of libsvm with Python bindings.
The install is very simple with MacPorts: sudo port install py27-scikit-learn (adapt py27 to whatever version of Python you use).
Seems like a old thread. Hope it helps someone else in the future.
I had the same problem. The solution is
- Run
makein libsvm-3.0 directory - Run
makein libsvm-3.0/python directory
If you did only at libsvm-3.0 folder you will face this issue. Do it at both the folders. Then it will work fine.
Instead of going through libsvm in order to access it with Python (I installed libsvm through MacPorts, and import svmutil fails), you might want to install the popular scikit-learn package, which contains an optimized version of libsvm with Python bindings.
The install is very simple with MacPorts: sudo port install py27-scikit-learn (adapt py27 to whatever version of Python you use).
SOLVED:
1. Navigate to http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsvm
2. Download the .whl file of libsvm corresponding to your OS.
3. Open command prompt and navigate to that folder containing the downloaded .whl file.
4. Type the following command in command prompt-
pip install libsvm-3.20-cp27-none-win32.whl
NOTE: Type name of your .whl file after pip install
I think there's no need to place the dll in the C:\windows\system32 directory unless you're using old versions of Windows (XP and older).
Make sure that:
- You launch your python test script containing
from svmutil import *inside the libsvm\python directory - You still have a copy of the libsvm dll in the libsvm\windows directory (if you moved it to C:\windows\system32, put a copy back in the libsvm\windows directory)
This works on my computer.
» pip install libsvm-official
Download and extract the zip or tar.gz. Run 'make' in the python directory to generate the shared library. You may need to add the location of the shared library to your path. The python modules are in the python directory. More information is found in the readme, also in the python directory.
Alternatively, follow the directions in the readme that's in the python_old directory.
There's also the main readme in the root of the archive.
This worked for me:
make
cd python
make PYTHON_INCLUDEDIR=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ LDFLAGS="-shared -lpython"
The -lpython was missing in my libsvm makefile, so I'm adding it here.
libsvm is a C++ package and has a python wrapper. You first need to install the libsvm package itself.
sudo apt install libsvm3
And then install the python wrapper.
sudo apt install python-libsvm
If you are on ubuntu you may use synaptic package manager. It would make life lot easier.
EDIT : For older version of OS, if you use apt-get, use apt-get instead of apt.
Have you tried
sudo pip install libsvm
or
sudo -H pip install libsvm