No module named Trilobot

Hello. I am trying to upload the examples onto my trilobot Rasberry Pi. But I keep getting the same error: ModuleNotFoundError: No module named ‘trilobot’

this is what I entered and received back:

eli@raspberrypi:~ $ cd ~/Pimoroni/trilobot/examples
eli@raspberrypi:~/Pimoroni/trilobot/examples $ python3 movements.py
Traceback (most recent call last):
File “/home/eli/Pimoroni/trilobot/examples/movements.py”, line 4, in
from trilobot import Trilobot
ModuleNotFoundError: No module named ‘trilobot’
eli@raspberrypi:~/Pimoroni/trilobot/examples $

…have you followed the instructions given here?

Hello thanks - yes I followed that exactly and got this message. I then did it again copying and pasting all the code to make sure, but it still returns the same message…

You could do the following:

In the file “/home/eli/Pimoroni/trilobot/examples/movements.py”, change line 4 from

from trilobot import Trilobot

Into

import trilobot

And try to run movements.py again…
This is just to make sure that the library you try to call in movements.py actually exists…

Rather than importing a class you import the whole library.

also, follow this thread, as this seems to be trilobot related.

Also, it might be worth to contact Kevin Mcalleer, as he is an expert in robotics and has a relation to Pimoroni…

…it just came to my mind that with the latest PiOS you need to install all stuff into a dedicated (and proper) environment…if not, it won’t run…

Thanks! I’m not sure how to do this. Any tips?

Also I just did the changes to line 4 and the same error came up

Is it exactly the error

ModuleNotFoundError: No module named ‘trilobot’

This would mean the library does not exist or not in the expected folder… this probably leads to a not propper installation in the right environment…
For the virtual environment, please see here, here and here

Basically, this is a four-step-process

  1. create virtual env (if not already existing)
  2. Activate virtual env for all further actions
  3. install again everything as above as regular (but this time in the activated env)
  4. Run programm (within the virtual env with all installations, libraries and dependancies…)

Which Raspberry Pi do you use for the trilobot and under which Raspberry Pi OS…?