Pynq z2: no module named pynq

when i use pynq z2 of official img,
i writed codes as follows:
import time
from pynq.overlays.base import BaseOverlay

base = BaseOverlay(“base.bit”)

while(Treu):
for led in base.leds:
led.toggle()
time.sleep(0.5)

this file is in another dir, /home/qqq/
file name is led.py
i use sudo python3 led.py ,
it raised an error :no module named pynq
thanks

PYNQ is installed in a virtual environment. To run a Python script you need to source the virtual environment first:
source /etc/profile.d/pynq_venv.sh

Cathal

1 Like

thanks a lot ,bro