Optommp error :No module named 'O22SIOUT'

Hi,

I am running the following python3 code and get this error. Running it on the epic in local (localhost).
Traceback (most recent call last):
File “optoMMP.py”, line 1, in
import optommp
File “/usr/lib/python3.4/site-packages/optommp/init.py”, line 1, in
import O22SIOUT
ImportError: No module named ‘O22SIOUT’

Code:
import optommp
import sys
grvEpic = optommp.O22MMP()
groov = optommp.O22MMP()
groov.SetDigitalPointState(int(sys.argv[1]),int (sys.argv[2]))
groov.close()

Can you help on solving it?

rgds

Hugues

Hi Hugues, welcome to the forums!

It looks like you’re one of the first people to use this module with python3 rather than Python 2.7. It was not originally written for python3, but I have found a workaround to get it running.

What it boils down to is that python3 handles relative imports differently than 2.7 so we’ll need to change line 1 of init.py to explicitly say where to find O22SIOUT.

Here’s my workaround:

  1. Download a copy of the same optommp repository that pip uses:
    wget https://github.com/optodeveloper/optommp/archive/refs/heads/master.zip

  2. Unzip the master file:
    unzip master.zip

  3. Delete the zip file (optional, but you won’t need it again):
    rm master.zip

  4. Navigate into the unzipped folder (this is also where I create and run my python3 script):
    cd optommp-master

  5. Open the init file with your text editor of choice:
    nano optommp/__init__.py
    or
    vim optommp/__init__.py

  6. Modify ONLY line 1, replacing “import O22SIOUT” with:
    from optommp import O22SIOUT

  7. Save the file. Now, in the optommp-master/ folder, you can create and run your python3 scripts using this modified module. There may be ways to get around the pathing, but the main thing is that the script should be in the same folder as the optommp subfolder.
    Then what should happen is that when you run the script here, instead of using the module you installed with pip at usr/lib/python3.4/site-packages/, python3 should use this modified version from wherever you unzipped the repo (in my case that’s just /home/opto/optommp-master/).


Please let me know if that does or doesn’t get you up and running, and again, welcome to the forums!

1 Like

Terry,

Thank you for the quick support.
I ll check it up tomorrow when I get back to the office. Meanwhile I have submitted a pull request on Github for it.