Python script error after PYNQ Z2 upgraded from V2.6 to V3.0

Hi,

I have python script running OK on PYNQ Z2 with image V2.6, but have encountered error when the board was upgraded to image version 3.0.1. The error is "ModuleNotFoundError: No module named ‘pynq’, when trying from pynq import Overlay in the script. Same error happened to image V2.7. It seems being a compatibility issue.

Please advise how to resolve this problem. Thanks.

@Luke2020

Need more info on the upgrade you had done, reimage the SD card?
While can Jupyter notebook terminal python import pynq return normal?

These two elements should have a good start to us what is going on.

Enjoy

@Luke2020 Are you sure you using the right python interpreter on the 3.0.1 version?
As @briansune more details would be very useful

Hi @Luke2020,

Are you running the script in the terminal? Since v2.7 we have been using a python virtual environment which you might need to activate. Can you try sourcing the following in your terminal before running your script?

source /etc/profile.d/pynq_venv.sh

If that doesn’t solve it we probably need a bit more info, as @briansune and @giop98 said :slight_smile:

All the best,
Shane

1 Like

Thanks @stf , @briansune and giop98 for all your feedback.

Sourcing the pynq_venv.sh seemed not solving the problem. See the screenshot below:

I currently try to run the python script in a terminal but eventually would like to make it run automatically after system bootup (this is all working under PYNQ V2.6).

For the 3.0.1 system, I’ve rebuilt the SD card with the V3.0 image downloaded using Imagewriter so it is a fresh new system. The import pynq works under jupyter notebooks web terminal.

Hope the above information would help to find out the cause. Thanks.

Luke

@Luke2020

This is a very old issue commonly found in 2.7 or older days:

While the composite overlay package is stable to use and got to install manually.
I also faced the same problem:

Usually if you want any action, use Jupter notebook to open terminal is the best way to make sure it is in the correct venv.

Enjoy~