开发者

Problem building libsvm-3.0 on CentOs 5.5 for Python-2.7.1

trying to install libsvm-3.0 for an alternative python build (python-2.7.1 instead of default 2.4) on CentOs 5.5. This python is installed in /opt/python2.7. I downloaded the source files and ran MAKE in the main dir and the python subdir. Then I copied everything to /opt/python2.7/lib/python2.7/site-packages/libsvm

When I did this on Macintosh 10.6.6, I had to do a couple of extra steps that were not i开发者_如何学Cn the instructions. They are described on my blog here. The key step was adding the following to svm.py

 import os.path
_PATH = os.path.join( *os.path.split(__file__)[:-1] )

and modifying this first statement

if find_library('svm'):
   libsvm = CDLL(find_library('svm'))
elif find_library('libsvm'):
   libsvm = CDLL(find_library('libsvm'))
else:
   if sys.platform == 'win32':
      libsvm = CDLL('../windows/libsvm.dll')
   else:
      libsvm = CDLL('../libsvm.so.2')

to look like this:

if find_library('svm'):
  libsvm = CDLL(find_library('svm'))
elif find_library('libsvm'):
  libsvm = CDLL(find_library('libsvm'))
else:
  if sys.platform == 'win32':
    libsvm = CDLL(os.path.join(_PATH,'windows','libsvm.dll'))
  else:
    libsvm = CDLL(os.path.join(_PATH,'libsvm.so.2'))

However, neither of these configurations are working on this Linux version. I am definitely not a Linux person, so I have no clue what could be wrong.

Working in the interpreter to try to figure this out, I noticed that cytpes.util.find_library('svm') or ctypes.util.find_library("libsvm.so.2") return empty values, so it definitely does not know where the .so is.

I was able to manually force the location in the interpreter by setting libsvm= CDLL(os.path.abspath("libsvm.so.2")). Then I could import svm during that session only.

Any help is much appreciated.

Mark


Okay, problem solved. Stupid me. Instead of adding __init__.py to the libsvm dir, I added init.py. Once I changed that, it works. Still, the need to add __init__.py should be included in the libsvm-3.0 installation notes IMHO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜