我使用python3编写了一个程序,该程序通过DNP3协议读取和响应数据,它打算在rpi3上运行。我在笔记本电脑上编写了代码,然后将其带到rpi,安装了所有依赖项,但出现了一个我不知道的错误不知道该怎么办:ModuleNotFoundError: No module named 'scapy'
我pip install scapy
成功安装了scapy 。
我是Python的新手,请帮帮我,tnx
我不认为这是相关的,但这是一段代码:
outstation.py:
from dnp3_lib import *
import datetime
from struct import pack, unpack
import sys
import socket
import random
SRC = 1023
DEST = 1010
START_B = b'\x05\x64'
port = 20000
transport_sequence = 0
try:
s = socket.socket()
print ("Socket successfully created!")
s.bind(('', port))
print ("Socket binded to %s" %(port))
s.listen(5)
print ("Socket is Listening...")
# Establish connection with client.
c, addr = s.accept()
print ('Got connection from', addr)
# counter = 0
while True:
try:
# Handle the requests and responces
except Exception as e:
print (e)
c.close()
exit()
c.close()
except socket.error:
print (">>> an err occurred !" + socket.error)
c.close()
exit()
dnp3_lib.py:
from scapy.all import *
import crcmod.predefined
import string
from struct import pack, unpack
.
.
.
# some functions to handle CRC and other things
我已评论,from scapy.all import *
并且显示(ModuleNotFoundError: No module named 'crcmod')
。我已经使用pip安装了crcmod。
在许多系统上,pip
默认设置为版本2,而不是版本3。最佳做法是始终输入pip2
或pip3
不使用default来指定所需的版本pip
。
在这种情况下,运行pip3 install scapy
应该可以解决该错误。
编辑:您还将另外需要运行pip3 install crcmod
,同样对于脚本所依赖的每个其他包也是如此。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句