gtbeean
I have done a few fresh installs of Raspbian Bullseye, and consistently see that pymodbus is not available to psm.
Install steps:
1. Raspberry Pi Imager, selecting Raspbian Bullseye Lite x64.
2. sudo apt update, sudo apt full-upgrade, reboot
4. git clone openplc_v3 and run ./ install.sh rpi
5. Start openplc service
6. Login at raspberrypi:8080
7. Change hardware to psm
8. Start PLC
 
 
Logs:
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
PSM: Starting PSM...
Traceback (most recent call last):
File "/home/openplc/OpenPLC_v3/webserver/./core/psm/main.py", line 27, in <module>
import psm
File "/home/openplc/OpenPLC_v3/webserver/core/psm/psm.py", line 3, in <module>
from pymodbus.server.sync import ModbusTcpServer
ModuleNotFoundError: No module named 'pymodbus'
PSM: Error while starting Python interpreter
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage() command
PSM: Connection to psm failed
PSM: Error connecting to psm!
PSM: PSM is disabled
Skipping configuration of Slave Devices (mbconfig.cfg file not found)
Warning: Persistent Storage file not found
 
 
I had a look within the OpenPLC install script, and it appears that the python dependencies are installed within a venv in the OpenPLC_v3 folder.
 
`pip freeze` after activating the venv shows pymodbus==2.5.3 is installed.
 
 
I had a look within the OpenPLC source code. I don't know c++, but I searched for "python" and found, within psm.cpp the following function.
psm.cpp no venv.png
 
The image shows the error message I see in the log, and also seems to show the psm.cpp isn't using the python executable from the venv, which is where all the dependencies are installed?
 
Please correct me, I very much expect to have missed something important somewhere!
 
Assuming I am wrong about this, please can someone help me fix my problem here?
 
 
Edit:
To be clear, I am using the blank_program and the default psm script.
Also, I have just tested on Raspbian 11 x86 and I get the same issue.
Reply 0 0
gtbeean
After continuing to mess around with the 32bit version of raspbian11, I've got PSM working.
All I had to do was run the following:
sudo apt install python3-pip
python3 -m pip install pymodbus==2.5.3
After doing so, psm starts fine with the blank program.
I've also installed the adafruit_circuitpython-pca9685 module with version 3.3.5 (not sure if I can use the newest version or not, but this version is working).
 
Oddly, I think I tried this on the 64bit version but it didn't work. I may be misremembering...
Reply 0 0
thiagoralves
I should update OpenPLC installation script to install pymodbus on system Python. Or maybe change PSM source code to use venv Python instead of system Python. The problem with using venv Python is that it becomes less obvious how to install Python libraries to be used with PSM. What do you guys think would be the best solution?
Reply 0 0
Paolo
I should update OpenPLC installation script to install pymodbus on system Python. Or maybe change PSM source code to use venv Python instead of system Python. The problem with using venv Python is that it becomes less obvious how to install Python libraries to be used with PSM. What do you guys think would be the best solution?
Hi !
Don't now what is the best solution...
 
And I've the same problem as @gtbeean on W10 x64
Traceback (most recent call last):
  File "/home/Paolo/OpenPLC_v3/webserver/./core/psm/main.py", line 27, in <module>
    import psm
  File "/home/Paolo/OpenPLC_v3/webserver/core/psm/psm.py", line 3, in <module>
    from pymodbus.server.sync import ModbusTcpServer
ModuleNotFoundError: No module named 'pymodbus'
But PowerShell cmd
pip install pymodbus
return
Requirement already satisfied: pymodbus in c:\python312\lib\site-packages (3.6.3)
Don't know if it's can help you and/or me
 


 
 
Reply 0 0
thiagoralves
Powershell will take you nowhere. You must install pymodbus on the Cygwin side. To open Cygwin, go to the folder where the OpenPLC Runtime was installed (typically c:\users\your-username\OpenPLC_Runtime) and you will see a link there to start Cygwin. Then from Cygwin you can type pip3 install pymodbus==2.5.3 and it should work
Reply 1 0
Paolo
Yes it's work !
 
Merci beaucoup
Reply 0 0
richw
Trying to install pymodbus on a RPI 5 and I'm getting "error: externally-managed-environment".  How do I install pymodbus so I can use PSM
Reply 0 0
thiagoralves
If I'm not mistaken, the latest version of the runtime installs pymodbus for PSM for you. You don't have to do anything
Reply 0 0
richw
Just did a fresh install of Raspberry PI  64 bit Bookworm , upgraded it and installed OpenPLC runtime. Set hardware to Python on Linux, try to start and receive error below.
 
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
PSM: Starting PSM...
Traceback (most recent call last):
File "/home/openplc/OpenPLC_v3/webserver/./core/psm/main.py", line 27, in <module>
import psm
File "/home/openplc/OpenPLC_v3/webserver/core/psm/psm.py", line 3, in <module>
from pymodbus.server.sync import ModbusTcpServer
ModuleNotFoundError: No module named 'pymodbus'
PSM: Error while starting Python interpreter
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued stop_dnp3() command
Issued stop_enip() command
Issued stop_pstorage() command
PSM: Connection to psm failed
PSM: Error connecting to psm!
PSM: PSM is disabled
Warning: Persistent Storage file not found
Reply 0 0
thiagoralves
This is what the installer runs to install PyModbus for PSM:
python3 -m pip install pymodbus==2.5.3
 
Try running this command on your terminal and check if you get any errors
Reply 0 0
richw
After running the command the response I get is
 
-bash: python3 -m pip install pymodbus==2.5.3: command not found
Reply 0 0
thiagoralves
How about
sudo apt install python3
 
And then type the python3 -m pip command?
Reply 0 0
gtbeean
Raspbian seems to prefer the use of venv over installing at the system level. I think updating the install script to use venv would be better for Raspberry Pi users. Not sure how this would affect cygwin though?
Reply 0 0
thiagoralves
OpenPLC uses venv, but PSM uses system Python to facilitate the use of user libraries when writing PSM code.
Reply 0 0
richw
unable to install pymodbus on RPI 5 with bookworm OS. none of the commands work. Spent many hours reinstalling OS and OpenPLC and still does not work.
Reply 0 0
Reply