New PYNQ 2.7 image got ModuleNotFoundError: No module named 'pynq' when install BNN-PYNQ

Because PYNQ 2.7 has Voila addon for Jupyter notebook, So I upgraded to 2.7.

When I try to install GitHub - Xilinx/BNN-PYNQ: Quantized Neural Networks (QNNs) on PYNQ by the command line

sudo pip3 install git+https://github.com/Xilinx/BNN-PYNQ.git 

But I got error message as below

sudo pip3 install git+https://github.com/Xilinx/BNN-PYNQ.git
Collecting git+https://github.com/Xilinx/BNN-PYNQ.git
  Cloning https://github.com/Xilinx/BNN-PYNQ.git to /tmp/pip-req-build-la0_4vuk
  Running command git clone -q https://github.com/Xilinx/BNN-PYNQ.git /tmp/pip-r                                                                                                             eq-build-la0_4vuk

  Resolved https://github.com/Xilinx/BNN-PYNQ.git to commit d39c1c75403db571f54dd0f0cf27ae5104ac968e
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/share/pynq-venv/bin/python3 /usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpqduv74yd
       cwd: /tmp/pip-req-build-la0_4vuk
  Complete output (22 lines):
  Traceback (most recent call last):
    File "/usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
      main()
    File "/usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 117, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 147, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 128, in _get_build_requires
      self.run_setup()
    File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 249, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 143, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 34, in <module>
      import bnn
    File "/tmp/pip-req-build-la0_4vuk/bnn/__init__.py", line 1, in <module>
      from .bnn import PynqBNN, CnvClassifier, LfcClassifier, RUNTIME_HW, RUNTIME_SW
    File "/tmp/pip-req-build-la0_4vuk/bnn/bnn.py", line 30, in <module>
      from pynq import Overlay, PL
  ModuleNotFoundError: No module named 'pynq'
  ----------------------------------------
WARNING: Discarding git+https://github.com/Xilinx/BNN-PYNQ.git. Command errored out with exit status 1: /usr/local/share/pynq-venv/bin/python3 /usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpqduv74yd Check the logs for full command output.
ERROR: Command errored out with exit status 1: /usr/local/share/pynq-venv/bin/python3 /usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpqduv74yd Check the logs for full command output.
WARNING: You are using pip version 21.2.1; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/local/share/pynq-venv/bin/python3 -m pip install --upgrade pip' command.

I check the pynq module location.

sudo pip3 show pynq
Name: pynq
Version: 2.7.0
Summary: (PY)thon productivity for zy(NQ)
Home-page: https://github.com/Xilinx/PYNQ
Author: Xilinx PYNQ Development Team
Author-email: pynq_support@xilinx.com
License: BSD 3-Clause
Location: /usr/local/share/pynq-venv/lib/python3.8/site-packages
Requires: numpy, cffi, setuptools, pandas
Required-by: pynq-peripherals

At first I tried to report it in BNN-PYNQ github. It is sad that the github was set to read-only. Can’t file in new issue. So I have to report it here.

1 Like

Hi,

BNN-PYNQ has been archived, the FINN team redirects to the finn-examples repo. There is no guarantee BNN-PYNQ will work on 2.7.

The pynq package is installed in a venv since 2.7. So, to avoid this error, you should add the --no-build-isolation switch. I recommend you run this from the terminal in JupyterLab?

python3 -m pip install git+https://github.com/Xilinx/BNN-PYNQ.git --no-build-isolation

Make sure CWD is /home/xilinx/jupyter_notebooks

Mario

1 Like

You may also use image v2.6.0, this may help

Hi atopet,
Thanks for your suggestion. The BNN-PYNQ works in PYNQ v2.6.x. However I encounter package dependence issue when install Volia. That is why I move to v2.7.0

Hi marioruiz,
I run into Jupyter Lab terminal, the result is same. So I will take a look of FINN-example for v2.7.0

root@pynq:/home/xilinx# cd jupyter_notebooks/
root@pynq:/home/xilinx/jupyter_notebooks# ls
 base   common   getting_started   logictools   pynq_peripherals  'Welcome to Pynq.ipynb'
root@pynq:/home/xilinx/jupyter_notebooks# pip3 install git+https://github.com/Xilinx/BNN-PYNQ.git
Collecting git+https://github.com/Xilinx/BNN-PYNQ.git
  Cloning https://github.com/Xilinx/BNN-PYNQ.git to /tmp/pip-req-build-20byhpki
  Running command git clone -q https://github.com/Xilinx/BNN-PYNQ.git /tmp/pip-req-build-20byhpki
  Resolved https://github.com/Xilinx/BNN-PYNQ.git to commit d39c1c75403db571f54dd0f0cf27ae5104ac968e
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/share/pynq-venv/bin/python3 /usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpu5szgkgh
       cwd: /tmp/pip-req-build-20byhpki
  Complete output (22 lines):
  Traceback (most recent call last):
    File "/usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
      main()
    File "/usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 117, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-zfeufaiw/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/tmp/pip-build-env-zfeufaiw/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-zfeufaiw/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 267, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-zfeufaiw/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 34, in <module>
      import bnn
    File "/tmp/pip-req-build-20byhpki/bnn/__init__.py", line 1, in <module>
      from .bnn import PynqBNN, CnvClassifier, LfcClassifier, RUNTIME_HW, RUNTIME_SW
    File "/tmp/pip-req-build-20byhpki/bnn/bnn.py", line 30, in <module>
      from pynq import Overlay, PL
  ModuleNotFoundError: No module named 'pynq'
  ----------------------------------------
WARNING: Discarding git+https://github.com/Xilinx/BNN-PYNQ.git. Command errored out with exit status 1: /usr/local/share/pynq-venv/bin/python3 /usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpu5szgkgh Check the logs for full command output.
ERROR: Command errored out with exit status 1: /usr/local/share/pynq-venv/bin/python3 /usr/local/share/pynq-venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpu5szgkgh Check the logs for full command output.
WARNING: You are using pip version 21.2.1; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/local/share/pynq-venv/bin/python3 -m pip install --upgrade pip' command.
root@pynq:/home/xilinx/jupyter_notebooks# 
1 Like

Once you have install all dependencies successfully for v2.7.0, you don’t need to rerun the dependencies for v2.6.x again, however, if necessary, you may just adjust your script or makefile for v2.6.x to match the viola version previously already installed.

Did you also try @marioruiz command? python3 -m pip install git+https://github.com/Xilinx/BNN-PYNQ.git --no-build-isolation

1 Like

You are missing the --no-build-isolation switch. I tested this in a 2.7 image and worked for me.

Ha! My bad eyes sight caused this switch was missing. After add this switch and run in Jupyter Lab terminal. BNN works again! Thanks for your great help.

2 Likes