ModuleNotFoundError: No module named 'pynq.iop' in PYNQ Z2

Getting error:
ModuleNotFoundError: No module named ‘pynq.iop’

Full code:
from pynq import Overlay
from pynq.iop import Pmod_OLED
from pynq.iop.iop_const import PMODB

ol = Overlay(“base.bit”)
ol.download()

pmod_oled = Pmod_OLED(PMODB)
pmod_oled.clear()
pmod_oled.write(‘Welcome to the\nPynq-Z1 board!’)


ModuleNotFoundError Traceback (most recent call last)
in ()
1 from pynq import Overlay
----> 2 from pynq.iop import Pmod_OLED
3 from pynq.iop.iop_const import PMODB
4
5 ol = Overlay(“base.bit”)

ModuleNotFoundError: No module named ‘pynq.iop’

Which board/image are you using, and what code/example are you trying to follow?

It looks like you are using something that is out of date.

In latest PYNQ version, pynq.iop module was replaced and functionality is in pynq.lib now.

For v2.5 PYNQ image, you can find an example of using Pmod OLED here:

Cathal