I am new to Python and trying to create a modbus server with pymodbus module. I follow tutorial on link, but when I run script I got an error:
$ python2.7 server1.py
INFO:pymodbus.server.async:Starting Modbus TCP Server on 192.168.1.100:502
Traceback (most recent call last):
File "server1.py", line 83, in <module>
StartTcpServer(context, address=("192.168.1.100", 502))
File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/server/async.py",
line 255, in StartTcpServer
reactor.listenTCP(address[1], factory, interface=address[0])
File "/home/pi/.local/lib/python2.7/site-
packages/twisted/internet/posixbase.py", line 495, in listenTCP
p.startListening()
File "/home/pi/.local/lib/python2.7/site-packages/twisted/internet/tcp.py",
line 1363, in startListening
raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on
192.168.1.100:502: [Errno 13] Permission denied.
Anyone can help me solve my problem, Thanks in advance.
[UPDATE]:
$ sudo python2.7 server1.py
Traceback (most recent call last):
File "server1.py", line 12, in <module>
from pymodbus.server.async import StartTcpServer
ImportError: No module named pymodbus.server.async
$ python -V
Python 2.7.13
$ sudo python server1.py
Traceback (most recent call last):
File "server1.py", line 12, in <module>
from pymodbus.server.async import StartTcpServer
ImportError: No module named pymodbus.server.async
I tried "sudo" already and got an error, it looks like when I use "sudo" the modules isn't on right spot...