[Ironpython-users] Latest status on ctypes?

Doug Blank doug.blank at gmail.com
Tue Mar 5 15:12:31 CET 2013


Looks like there are at least two issues: one where the platform is
not known (and doesn't know what low level library to open), but the
lower level issue seems to be:

$ mono ./ipy64.exe
IronPython 2.7.3 (2.7.0.40) on Mono 4.0.30319.1 (64-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import dlopen
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dblank/Desktop/IronPython-2.7.3/Lib/ctypes/__init__.py",
line 441, in <module>
  File "/home/dblank/Desktop/IronPython-2.7.3/Lib/ctypes/__init__.py",
line 353, in __init__
OSError: IronPython.Runtime.Exceptions.OSException: cannot load library
  at IronPython.Modules.CTypes.LoadLibrary (System.String library,
Int32 mode) [0x00000] in <filename unknown>:0
  at IronPython.Modules.CTypes.dlopen (System.String library, Int32
mode) [0x00000] in <filename unknown>:0
  at Microsoft.Scripting.Interpreter.FuncCallInstruction`3[System.String,System.Int32,System.Object].Run
(Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in
<filename unknown>:0
  at Microsoft.Scripting.Interpreter.Interpreter.Run
(Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in
<filename unknown>:0
>>> from _ctypes import dlopen
>>> dlopen("/usr/lib/libpython2.7.so")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: IronPython.Runtime.Exceptions.OSException: cannot load
library /usr/lib/libpython2.7.so
  at IronPython.Modules.CTypes.LoadLibrary (System.String library,
Int32 mode) [0x00000] in <filename unknown>:0
  at IronPython.Modules.CTypes.dlopen (System.String library, Int32
mode) [0x00000] in <filename unknown>:0
  at Microsoft.Scripting.Interpreter.FuncCallInstruction`3[System.String,System.Int32,System.Object].Run
(Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in
<filename unknown>:0
  at Microsoft.Scripting.Interpreter.Interpreter.Run
(Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in
<filename unknown>:0

libpython2.7.so does exist, but LoadLibrary doesn't appear to be able
to deal with it. Am I using this correctly?

-Doug

On Mon, Mar 4, 2013 at 4:47 PM, Jeff Hardy <jdhardy at gmail.com> wrote:
> On Mon, Mar 4, 2013 at 1:01 PM, Doug Blank <doug.blank at gmail.com> wrote:
>> Wondering what the status is on ctypes with IronPython. I had an older
>> version of ctypes.py that was referencing a previous dll:
>>
>> ImportError: No module named IronPython.Runtime.Calls
>>
>> The CPython 2.7 ctypes directory doesn't load:
>>
>> python>>> import ctypes
>> Traceback (most recent call last):
>>   File "<string>", line 1, in <module>
>>   File "/home/dblank/Calico/trunk/bin/Lib/ctypes/__init__.py", line
>> 441, in <module>
>>   File "/home/dblank/Calico/trunk/bin/Lib/ctypes/__init__.py", line
>> 353, in __init__
>> OSError: IronPython.Runtime.Exceptions.OSException: cannot load library
>>   at IronPython.Modules.CTypes.LoadLibrary (System.String library,
>> Int32 mode) [0x00000] in <filename unknown>:0
>>   at IronPython.Modules.CTypes.dlopen (System.String library, Int32
>> mode) [0x00000] in <filename unknown>:0
>>   at Microsoft.Scripting.Interpreter.FuncCallInstruction`3[System.String,System.Int32,System.Object].Run
>> (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in
>> <filename unknown>:0
>>   at Microsoft.Scripting.Interpreter.Interpreter.Run
>> (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in
>> <filename unknown>:0
>>
>> Any info would be useful; thanks!
>
> It looks like you're on a Unix box. I'm pretty sure IronPython ctypes
> has only ever been tested on Windows, so it could have some
> platform-specific dependencies. If you could figure out what library
> it's failing to load, that might help sort it out. Make sure you're
> using IronPython's copy of the stdlib as well, since it may have some
> modifications to make it work.
>
> - Jeff


More information about the Ironpython-users mailing list