top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Unable to import NHunspell.dll using ctypes in Python

0 votes

Im required to import ha 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['Hunspellx64.dll']

I get an error

 hunspell = cdll.LoadLibrary['Hunspellx64.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.

posted Jun 25, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
 >>> from ctypes import *
 >>> help(cdll.LoadLibrary)

Help on method LoadLibrary in module ctypes:

LoadLibrary(self, name) method of ctypes.LibraryLoader instance.

So looks as if you need:-

hunspell = cdll.LoadLibrary('Hunspellx64.dll')
answer Jun 25, 2013 by anonymous
Similar Questions
0 votes

I would like to use the Gen3.dll functions from python. I understand that I can use ctypes to load the dll. I have been able to load the dll but cannot make any sense of how to use it once I have it loaded. I have been trying to understand the ctypes tutorial but I just can't wrap my head around it. I have attached a zip file of everything I have about the dll, including the Gen3.dll. Can someone point me in the right direction. My hopes are that I can automate the functions to provide a test program. The Gen3.dll communicates to a piece of hardware over a USB cable. Its mainly for setting voltages and loads and reading results.

+2 votes

I have a pile of C code that I wrote that I want to interface to via the ctypes module ( ).

The C code uses the Boehm-Demers-Weiser garbage collector ( ) for all of its memory management. What I want to know is, who owns allocated memory? That is, if my C code allocates memory via GC_MALLOC() (the standard call for allocating memory in the garbage collector), and I access some object via ctypes in python, will the python garbage collector assume that it owns it and attempt to dispose of it when it goes out of scope?

Ideally, the memory is owned by the side that created it, with the other side simply referencing it, but I want to be sure before I invest a lot of time interfacing the two sides together.

0 votes

Is it possible to call a Python macro from ctypes? For example, Python 3.3 introduces some new macros for querying the internal representation of strings:

So I try this in 3.3:

py> import ctypes
py> ctypes.pythonapi.PyUnicode_MAX_CHAR_VALUE
Traceback (most recent call last):
 File "", line 1, in 
 File "/usr/local/lib/python3.3/ctypes/", line 366, in __getattr__
 func = self.__getitem__(name)
 File "/usr/local/lib/python3.3/ctypes/", line 371, in __getitem__
 func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python3.3: undefined symbol: PyUnicode_MAX_CHAR_VALUE
+1 vote

I want to read the combo box in excel by using "xlrd" but in the output it is showing empty message, its not reading the combo box can u guys help me how to read the combo box in excel by "xlrd"

code written like this

workbook = xlrd.open_workbook('path of the file')
worksheet = workbook.sheet_by_name('sheetname')
TargetSystem = worksheet.cell_value(4, 2)
0 votes

I want to know how relative imports (in Python) are different than import. I have found lots of examples on internet explaining about the relative import but I want to know about the basic aspects of relative import that make it different than import.