[Ironpython-users] import error: scapy on ironpython (windows)

Jeff Hardy jdhardy at gmail.com
Sun Apr 26 00:33:26 CEST 2015


On Mon, Apr 6, 2015 at 6:07 PM, Hemanth M B <hemanth at broadcom.com> wrote:
> Hi All,
>
>
>
> I am facing problem to import scapy.all in ironpython shell. It is throwing
> an error mentioned below:
>
>
>
>>>> from scapy.all import *
>
> Traceback (most recent call last):
>
>   File "<stdin>", line 1, in <module>
>
>   File "C:\Program Files (x86)\IronPython
> 2.7\lib\site-packages\scapy\all.py", line 16, in <module>
>
>   File "C:\Program Files (x86)\IronPython
> 2.7\lib\site-packages\scapy\arch\__init__.py", line 54, in <module>
>
> AttributeError: 'module' object has no attribute 'uname'
>
>
>
> Note:
>
> I have installed scapy using command “ipy -X:Frames -m pip install scapy”
> and it got installed. As I verified with the scapy official website, one of
> the prerequisite is pywin32. At par to my knowledge ironpython doesn’t
> support pywin32.

Hi Hemanth,
Apologies for the delay, April has been ... interesting? ... for me.

You're right that IronPython does not support pywin32, because
IronPython doesn't support C extensions in general. In this specific
case it's probably because scapy checks for Windows using sys.platform
== 'win32' instead of os.name == 'nt' and it's trying to run a Unix
codepath (uname is the giveaway, it's part of os on Unix but not
Windows).

It might be possible to replace the calls into pywin32 with ctypes
calls but it would require changing scapy.

- Jeff


More information about the Ironpython-users mailing list