The difficult is that enchant has a few dependencies that aren't
installed by default on the Mac. If requires an installation of glib:
http://ftp.gnome.org/pub/gnome/sources/glib/2.24/
As well as a spellchecking backend like aspell:
Installing all of these from source is, frankly, not for the faint of
heart.
I *strongly* recommend using macports. This is an automated build
system that will download the necessary sources, configure and install
them for you with a single command:
http://www.macports.org/install.php
Once you have installed macports, this command should be all that's
required to get you up and running with PyEnchant:
> sudo port install enchant aspell-dict-en
> PS : the use of easy_install fpor pyenchant on a Mac seems to work.
> The only problem is the preceding one with the C library enchant.
Yes, eventually I will bundle a prebuilt enchant library into some eggs
for OSX, I just haven't got around to it yet...
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
ry...@rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
I won't be surprised if that breaks things, enchant tends to look for
its dictionaries etc relative to the location of the main enchant
library.
Where did the enchant library end up after installing by macports?
Enchant *should* be looking in /opt/local/lib/ by default.
> Then I've the following error :
> >>> import enchant
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/site-packages/pyenchant-1.6.2-py2.6.egg/enchant/
> __init__.py", line 91, in <module>
> from enchant import _enchant as _e
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/site-packages/pyenchant-1.6.2-py2.6.egg/enchant/
> _enchant.py", line 55, in <module>
> from enchant import utils
> ImportError: cannot import name utils
> ==========================================================================================
>
> What's missing ?
OK, a couple of things to try:
* can you import "enchant.utils" directly from the python prompt? If
so, this suggests a relative-import problem, possibly because of
additional files in the enchant package directory. Please send a list
of all the files in your enchant package dir.
* remove the compiled enchant lib from the folder with _enchant.py,
and instead set the path to it in the environment variable
PYENCHANT_LIBRARY_PATH. Example:
#> PYENCHANT_LIBRARY_PATH=/opt/local/lib/libenchant.dylib python
>>> import enchant
>>>
As a last resort, you can edit the _enchant.py file directory to point
it at the correct location of the compiled enchant library.
Ah, now we see that your aversion to macports was a least partially
justified :-(
It looks like macports has built only the 32-bit version of enchant, but
python is looking for the 64-bit version.
Try taking a look in /opt/local/etc/macports.conf for the "os.arch"
setting. If it's set to "i386", change it to "x86_64" and rebuild
enchant.
(or if you're feeling adventurous, try to build it as a universal binary
- but you'll have to consult the macports guide for how to do that)
You might have some luck with the various python aspell wrappers - just
google "python aspell" and you should find one. But again, they depend
on compiling and installing an underlying spell-checking engine.
Hmmm. Are you using the python version that came installed with the
mac, or a different version? Perhaps python is expecting 32-bit
libraries and enchant is only built 64-bit.
> Is there at least one way to test in the Terminalm that enchant
> works ?
Sorry, I don't have access to my Mac at the moment to test it out, but
you should be able to run "enchant-lsmod" from the command line. This
lists the backends available to enchant, if you get at least one line of
output then enchant should be working on your system.
> I will seek to another way to spell text on Windows, Linux and Mac at
> the same time because it's too complicated for the moment to use yor
> library which is very usefull. Why don't you build something that will
> work on a Mac ?
I'm really not sure how to take that last comment. The answer, as
usual, is that I do this in my spare time and it hasn't been a priority
for me. I will *try* to include pre-built version in the next release.
Regardless, this usually does work on the mac. The procedure I
suggested using macports has worked for me and at least two other people
who have bothered to report their success to me.
It's possible this problem is unique to Snow Leopard and the particular
variant of python you have installed. When I get a chance I'll try it
again using both the default system python and the one from python.org.
If you find an alternate spell-checking library that works for you on
the mac, please report your success to the list so that anyone who finds
this thread in Google can have some resolution. It's always good to
have a record of what works and what doesn't.
Cheers,
Try "enchant-lsmod" for a start, this will list the installed enchant
spelling providers.
That looks about right, I'd say your enchant library is definitely
working.
OK, I will try to test under that scenario and see what the solution is.
One option would be to built enchant as "universal". Try putting
"+universal" in the file /opt/local/etc/macports/variants.conf and
re-building enchant and its dependencies.
(I don't recall the exact syntax for the variants.conf file sorry, but I
think adding +universal should do it)
> > I'm really not sure how to take that last comment. The answer, as
> > usual, is that I do this in my spare time and it hasn't been a priority
> > for me. I will *try* to include pre-built version in the next release.
>
> That was just a remark and I do not ask you to do the job. Sorry if I
> hurted you.
No problem. I haven't been getting much sleep lately so I'm sorry if I
was snarky.
These are all bugs and corner-cases that I would have come across
eventually, so it's good that you're helping me ferret them out :-)