How to build libsvm-2.91 for Python on OS X 10.6.4 Snow Leopard using SWIG 2.0?

0

1

Problem:

I've inherited work on a Django we app that makes use Python modules that import svmc. When I type ./manage.py runserver I get the following:

Error: No module named svmc

Solution sought:

sh > python
>>> import svmc
>>>

More bits and pieces:

So I asked a related question, which was answered, and led me here, since I can't seem to perform the necessary steps mentioned in the solution provided by said answer.

On my other machine (Linux, Ubuntu, Lucid Lynx), I've been able to install quite nicely with the package manager apt-get. I'm using Homebrew for my OS X package manager, and would prefer to avoid Darwinports, Macports or Fink to install libsvm.

My environment:

  • Mac OS X 10.6.4 Snow Leopard on Intel-based x86_64 architecture
  • GCC 4.2
  • SWIG 2.0
  • Python (64-bit)
  • Django 1.2.1
  • setuptools, disutils, and more!

What I've Tried:

  • I downloaded libsvm-2.91 from http://www.csie.ntu.edu.tw/~cjlin/libsvm/
  • I unpack file, cd into python, ran make, put libsvm.so.1 and svm.so on PATH in .bash_profile, and I got the same error: no module named svmc.
  • I looked at the .py files in my project referencing svmc, and noted that the only references to svmc are in the python_old directory of the downloaded files (libsvm-2.91)
  • I downloaded SWIG 2.0 and installed it
  • cd into libsvm-2.91/python_old

Finally, I ran (inside libsvm-2.91/python_old): sudo make cleaner rm -f *~ *.o *.so *.pyc *.pyo rm -f svmc_wrap.c sudo make all

Truncated screen vomit:

 "_PyLong_Type", referenced from:
      SWIG_AsVal_long(_object*, long*) in svmc_wrap.o
      SWIG_AsVal_double(_object*, double*)in svmc_wrap.o
      SWIG_AsVal_unsigned_SS_long(_object*, unsigned long*)in svmc_wrap.o
 "_PyObject_Init", referenced from:
     _PySwigObject_dealloc in svmc_wrap.o
     _SWIG_Python_NewPointerObj in svmc_wrap.o
     _initsvmc in svmc_wrap.o
...

"_PyTuple_SetItem", referenced from:
  _PySwigObject_format in svmc_wrap.o

ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [svmc.so] Error 1

I would greatly appreciate any help, ideas, suggestions, or comments! Thank you, Michaux

mkelley33

Posted 2010-07-05T22:25:59.583

Reputation: 166

Answers

1

OK. So I don't know that I can truly answer this question. If anyone who stumbles across this seems to know the answer, and would like to replace my pseudo-answer, then please leave a comment, and I will change my answer to a comment, and replace it with a better answer.

Ultimately I was just trying to arrive at the solution stated above in the original question. I have in fact reached a solution that works just fine:

Download and run pyvision included installer!

Open a terminal and paste the following line:

svn co https://pyvision.svn.sourceforge.net/svnroot/pyvision/trunk pyvision

Once you've got it type:

cd pyvision/R/libsvm/python/
python setup.py install

And now you'll be able to open a terminal and type:

python
>>> import svmc
>>>

Voila! No errors, and libsvm hotness (Version 2.84, which should work fine in most situations--Please feel free to correct me!)

Thank you, and good luck to all my Macintosh OS X people out there! Michaux

mkelley33

Posted 2010-07-05T22:25:59.583

Reputation: 166