0

I'm required to import a certain dll called 'NHunspell.dll' which is used for Spell Checking purposes. I am using Python for the software. Although I checked out several websites to properly use ctypes, I have been unable to load the dll properly.

When I use this code.

  from ctypes import *
  hunspell = cdll.LoadLibrary['NHunspell.dll']

I get an error

  hunspell = cdll.LoadLibrary['NHunspell.dll']
  TypeError: 'instancemethod' object has no attribute '__getitem__'

I guess it might a problem with the structure of the dll. But I have no idea how to import the dll properly.

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
  • `LoadLibrary` is a function so try `hunspell = cdll.LoadLibrary('NHunspell.dll')` – Pragmateek Jun 25 '13 at 10:36
  • `cdll` is designed for use on Windows, where you can just use `cdll.nhunspell`. On other platforms, use `CDLL(...)`. Also, [NHunspell](http://sourceforge.net/projects/nhunspell/files) is .NET; it won't have exported symbols for use with ctypes. You could use the C API for [Hunspell](http://sourceforge.net/projects/hunspell/files/Hunspell). – Eryk Sun Jun 25 '13 at 11:14

1 Answers1

0

Thanks @eryksun . But it still did not work. I instead used a Python wrapper for Hunspell called Pyhunspell. The actual link in PyPi does not work for Python 2.7 but it has been improved and upgraded in here.

  • Link in this answer is dead. pyhunspell moved a lot since then too. Here is the new link : https://github.com/blatinier/pyhunspell. – Benoît Latinier Mar 19 '16 at 21:55