ImportError:无法导入名称转换

时间:2020-07-26 08:14:42

标签: python python-2.7 jython scapy

我正在使用jython通过Java调用我的python脚本。 python脚本具有一个scapy模块(Python版本:2.7)。当我使用以下代码拨打电话时,我收到以下异常

    from scapy.all import *
  File "/Users/Library/Python/2.7/lib/python/site-packages/scapy/all.py", line 18, in <module>
    from scapy.arch import *
  File "/Users/Library/Python/2.7/lib/python/site-packages/scapy/arch/__init__.py", line 28, in <module>
    from scapy.arch.bpf.core import get_if_raw_addr
  File "/Users/Library/Python/2.7/lib/python/site-packages/scapy/arch/bpf/core.py", line 9, in <module>
    from ctypes import cdll, cast, pointer
ImportError: cannot import name cast

我的Java代码:

import org.python.core.*;

public class PythonCall {
    
public static void main(String[] args) {
    PythonInterpreter interp = new PythonInterpreter();
    interp.execfile("/Users/python_projects/PacketTrace/nettracer/DebugMonitor.py");
    
}
}

我的python代码:

import os
os.sys.path.append('/Users/Library/Python/2.7/lib/python/site-packages')
print os.sys.path
from scapy.all import *
from scapy.layers.http import HTTPRequest,HTTPResponse,HTTP 

class DebugMonitor(object):

def __init__(self):
        '''
        Constructor
        '''
        print "Debugging" 
        self.packetSniff()

def packetSniff(): 
      <Code to Sniff packets> 

if __name__ == '__main__':
    print os.sys.path
    os.sys.path.append('/Users/Library/Python/2.7/lib/python/site-packages')
    debug = DebugMonitor()

任何人遇到此问题,我们将不胜感激。

0 个答案:

没有答案