Installing PyLucene on a Mac
Asked Answered
C

2

7

I would like to be able to use pyLucene on my Mac. The instructions have me hopelessly lost because each instruction for setting up or making requires that I do something before it, and it's hard to know where to start and what to do from what window.

I have downloaded PyLucene. The first thing I'm wondering is where I put the folder, since that doesn't seem self-evident to me.

To use it, I am told I need to build JCC, which is included in the pylucene download.

The instructions:

At the command line, enter:

$ python setup.py build
$ sudo python setup.py install

But to do this, I think, I need to be in the right place or put the folder in the right place because otherwise I'm getting "setup.py" not found.

Any help you can offer on this environment (A shell window? An IDE?). Any help on getting pas this first part: building JCC, followed by setting up pylucene is much appreciated.

Confucius answered 17/1, 2013 at 10:3 Comment(0)
A
9

This works on recent macOS versions. First, make sure you install:

Then add to your ~/.bash_profile:

export JAVA_HOME=$(/usr/libexec/java_home)

Then, reload your shell.

Download PyLucene and extract the folder, cd to it from your shell. Now, follow the instructions from the official installation guide:

cd jcc
python setup.py build

Now, install JCC:

python setup.py install

(A sudo may be required if you are using the macOS system Python.)

Now go back to the parent folder and edit the Makefile. Replace the uncommented lines as instructed with the actual path to ant, python, jcc, and the NUM_FILES:

ANT=ant
PYTHON=python
JCC=python -m jcc
NUM_FILES=8

Now build PyLucene:

make
make test

Finally, to install the built PyLucene:

make install

(You may need sudo if using the system Python.)

Ably answered 9/8, 2017 at 12:7 Comment(1)
Thanks a lot! that works perfectly!. Will surely try out things next time!Bruell
E
3

Download pre-built JCC and pylucene eggs for Mac from here.

As of now, the latest versions are JCC-2.8 and lucene-3.1.0 for python 2.6, so below I'll use easy_install-2.6 and python2.6.

Install them:

$ sudo easy_install-2.6 JCC-*.egg
$ sudo easy_install-2.6 lucene-*.egg

Test:

$ python2.6
>>> import jcc
>>> import lucene
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/lucene-3.1.0-py2.6-macosx-10.6-universal.egg/lucene/__init__.py", line 7, in <module>
    import _lucene
ImportError: dlopen(/Library/Python/2.6/site-packages/lucene-3.1.0-py2.6-macosx-10.6-universal.egg/lucene/_lucene.so, 2): Library not loaded: @rpath/libjcc.dylib
  Referenced from: /Library/Python/2.6/site-packages/lucene-3.1.0-py2.6-macosx-10.6-universal.egg/lucene/_lucene.so
  Reason: image not found

If you get the above error, fix it by simply creating symlink of libjcc.dylib in /usr/local/lib/. libjcc.dylib should be inside site-packages/JCC-*.egg/.

>>> jcc.__file__
'/Library/Python/2.6/site-packages/JCC-2.8-py2.6-macosx-10.7-intel.egg/jcc/__init__.pyc'
>>> ^D

$ ln -s /Library/Python/2.6/site-packages/JCC-2.8-py2.6-macosx-10.7-intel.egg/libjcc.dylib /usr/local/lib/

$ python2.6
>>> import jcc, lucene
>>> 
Edile answered 28/6, 2013 at 22:45 Comment(2)
This worked for me! The combination of special versions and symlinks was not obvious at all, thanks a bunch.Hoeve
@Tarun See my answer below, I just followed the official guide.Ably

© 2022 - 2024 — McMap. All rights reserved.