RevPiModIO Import Error: Resolving Python 3 Setup Guide

Jason IP4 min read
Other ManufacturerOther TopicTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

The error ImportError: No module named revpimodio2 on a RevPi Connect running a Stretch image does not establish a hardware-compatibility problem. The supplied case was caused by installing the Python 3 package but launching the application with Python instead of Python 3. After correcting the interpreter, treat cycle-time warnings as a separate execution-performance issue.

Identify the Import Failure

Observation Supported interpretation Action
No module named revpimodio2 The active interpreter cannot locate the module. Install the Python 3 package and run the application with Python 3.
RevPi Connect with a Stretch image The evidence states that RevPiModIO is not restricted to RevPi Core hardware. Check the software environment before treating the controller model as the cause.
Import works after changing the Geany command Geany had been launching Python rather than Python 3. Keep the editor's build and execute commands aligned with the interpreter that owns the package.

Install RevPiModIO for Python 3

Update the package catalog and install the repository package with these commands:

sudo apt-get update
sudo apt-get install python3-revpimodio2

Then launch the program with python3, not python. An installation performed for Python 3 does not guarantee that a command named python uses the same interpreter or package path.

Configure and Verify the Geany Interpreter

  1. Open the Geany build-command configuration used to execute the script.
  2. Change the execute command from Python to Python 3 without guessing a module path or copying package files manually.
  3. Run a minimal import through that same Geany command:
    import revpimodio2
    print(revpimodio2)
  4. Confirm that the script completes without No module named revpimodio2. If a terminal launch succeeds while Geany fails, the two launch paths are still using different interpreter environments.

Interpret RevPiModIO Cycle-Time Warnings

After the import is fixed, either of these warnings indicates a timing or callback backlog, not another installation failure:

RuntimeWarning: cycle time of 20 ms exceeded several times - can not hold cycle time!
RuntimeWarning: can not execute all event functions in one cycle - optimize your event functions or rise .cycletime

The cycle time controls how often inputs and outputs are updated. A signal that changes from true to false and back to true entirely within one cycle cannot be detected. The evidence identifies 20 ms as the default and states that values below the piBridge cycle time, starting at 10 ms, provide no benefit. It also states that 20 ms is supportable on a Revolution Pi Core-3 or Connect.

With .cycleloop(...), the cycle function must finish within the configured cycle time. With .mainloop(), event functions normally run one at a time in event order. A slow callback—such as one containing a sleep, a long loop, or slow network communication—delays later callbacks in the queue. For example, ten events in one second combined with a callback that runs for about one second can leave processing about ten seconds behind.

RevPiModIO version 2.4.2 changed repeated-warning behavior so the message appears only once; it did not turn the underlying overrun into a software bug or eliminate the backlog.

Correct Timing Problems Safely

  1. Measure or inspect each cycle and event function for sleeps, long loops, blocking network operations, and other work that prevents timely return.
  2. Shorten the callback or move slow work outside the time-critical path. Keep 20 ms when the controller can sustain it because increasing the cycle time reduces input-change resolution.
  3. Increase .cycletime only after confirming that the process can tolerate the longer I/O update interval. A tested value of 100 ms removed the warning in the supplied case, but the evidence does not establish that value as suitable for every machine.
  4. Use .reg_event(..., as_thread=True) only when parallel callbacks are intentional. Threaded callbacks can overlap, manipulate the same output in conflicting order, or create an unbounded number of concurrent executions if events arrive faster than the callback completes.
  5. Do not use autorefresh=False or comment out the warning in helper.py as the corrective action. Those changes can hide the monitored condition without proving that I/O updates and event processing meet the application's timing requirements.

Verify the correction under the fastest expected input activity. Confirm that cycle-time warnings do not recur, event processing does not fall progressively behind, brief input transitions that matter to the process are detected, and outputs remain deterministic. If threading is enabled, explicitly prevent callback re-entry where required and coordinate every shared output.

FAQ

Why does RevPi Connect report no module named revpimodio2?

The supported case used the wrong interpreter. Install python3-revpimodio2 and configure the terminal or Geany command to run the program with Python 3.

What does the RevPiModIO 20 ms cycle-time warning mean?

RevPiModIO could not consistently complete the required update or callback work within the 20 ms cycle. Check cycle functions and event callbacks for sleeps, long loops, or slow network operations.

Is reg_event as_thread=True safe for slow callbacks?

It permits callbacks to run concurrently, but every event can start another execution even while the previous one is active. Use it only with re-entry control and deterministic coordination of shared outputs.

Back to blog