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.
This works on recent macOS versions. First, make sure you install:
brew install ant --with-ivy
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.)
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
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With