pythonpippymodbus

Raspberry pi modulenotfounderror pymodbustcp


On my raspberry pi 4 I tried to code some basic stuff (like printing messages) to test out the pymodbustcp. I got the code from the pymodbustcp wiki so that shouldn't give the problem. For some reason, it doesn't want to find the module of pymodbustcp and it gives this message below when I run the code. I think it has to do with pip but I am not sure

/home/pi/Desktop/Laadpunt/venv/bin/python /home/pi/Desktop/Laadpunt/main.py
Traceback (most recent call last):
  File "/home/pi/Desktop/Laadpunt/main.py", line 7, in <module>
    from pyModbusTCP.client import ModbusClient
ModuleNotFoundError: No module named 'pyModbusTCP'
Process finished with exit code 1

I installed both "sudo pip2 install pyModbusTCP" as "sudo pip3 install pyModbusTCP" in my console and that says:

pi@raspberrypi:~ $ sudo pip install pyModbusTCP
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 6, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
pi@raspberrypi:~ $ 

What could be the reason for the issue and how would I fix it?? If you need any info from commands tell me which ones.


Solution

  • sudo pip is not the way to go to install to your venv.

    You should install to your venv specifically by doing

    /home/pi/Desktop/Laadpunt/venv/bin/python -m pip install ...