# No Module called "pynq"

**URL:** <https://discuss.pynq.io/t/no-module-called-pynq/3513>\
**Category:** Support\
**Created:** [January 8, 2022, 2:32pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513 "2022-01-08T14:32:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 8, 2022, 2:32pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/1 "2022-01-08T14:32:47Z")

</div>

I have build an image for TE0802 Ultrascale board using the aarch64 rootfs file and the bsp for this board and executed the command below at the PYNQ/sdbuild directory.  
bash scripts/image\_from\_prebuilt.sh TE0802 xilinx-te0802-2020.1.bsp aarch64 focal.aarch64.2.7.0\_2021\_11\_17.tar.gz

It successfully generated the TE0802-2.7.0.img in its output folder.

I then use win32diskimager, and write the TE0802-2.7.0.img successfully. Inserted the SD card and boot up TE0802.

However when I try to run an inference from my Host PC via RPC ssh, it says the target device has no module called “Pynq”.

On the TE0802, I ran $python -m site

 ![Screenshot from 2022-01-07 17-22-10](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/5/58259560d67bf28b3dffa747d60cf2539e9901c2.png)

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [January 10, 2022, 11:13am UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/2 "2022-01-10T11:13:24Z")

</div>

Hi there,

What exactly are you running to cause the “the target device has no module called “Pynq””? And are you running that from inside the pynq virtualenv? Could you try running these commands as root, first sourcing the virtualenv with `source /etc/profile.d/pynq_venv.sh`

Thanks  
Shawn

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 11, 2022, 2:05pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/3 "2022-01-11T14:05:52Z")

</div>

Hello,

Thank you for your reply,

I am currently running inference of ONNX model via RPC to FPGA, which requires pynq driver to port the model. I used the Pynq image downloaded online for Z1 and the inference went okay, but Z1 has some limited resources so I am now using of TE0802. As earlier explained I have the .img created which was burned into as SD card.

For your advice, I have cleaned and make a new environment, change to root (sudo su) and sourced the virtualenv with `source /etc/profile.d/pynq_venv.sh` which now append the pynq-venv. However, I still have the same error on the host side RPC Error of target device ‘No module named pynq’

![Screenshot from 2022-01-10 16-57-38](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/7/767aa5af116a07e79a95d4e07f071125c25acebe.png)

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [January 11, 2022, 4:17pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/4 "2022-01-11T16:17:13Z")

</div>

So, if I am understanding correctly, you are running an application on your host, and sending commands with rtc over ssh to an application running on your target? Are you able to import pynq on the target over a regular ssh session (without rtc)?

A bit more info on the application and commands you are running would be useful.

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 13, 2022, 5:18pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/5 "2022-01-13T17:18:26Z")

</div>

Hi,

On a regular ssh session, import pynq on the target FPGA returns, see image below

 ![Screenshot from 2022-01-13 18-03-01](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/5/57f11466cbde1f0eb040b0267035920651a259f2.png)

I am working on Apache TVM environment to run a model on TE0802 Ultrascale via cross-compilation. (RPC). I ran same module on PYNQ-Z1 and no such error, I tried using the image created for TE0802, then I meet the error I earlier complained.

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [January 13, 2022, 8:58pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/6 "2022-01-13T20:58:29Z")

</div>

Ok… Good to know that at least pynq works in a regular session. It is a bit strange that your application would run on a Z1 and not on your board, because there shouldn’t be any filesystem changes. Have you installed your target application the same way on both boards?

It seems like for some reason it doesn’t pick up the right python path on the TE0802. Do you by any chance launch your rpc server with sudo, as in `sudo start_rpc_server.sh`? If you do this and you sourced the virtual environment as a regular user beforehand it will run it as root without the paths for correctly importing pynq. In that case you should probably login as root first, then source the virtual env, then launch your server without sudo.

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 13, 2022, 10:01pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/7 "2022-01-13T22:01:44Z")

</div>

Thank you once again.

I login as root first, then source the virtual env, then launch my server without sudo, still same result.

Here’s my flow

1. On host PC  
ssh [xilinx@192.168.2.99](mailto:xilinx@192.168.2.99) (it appears as xilinx@pynq$)

2. Make root  
Sudo su (it appears as root@pynq$)

3. Source Virtual Environment (it appears as (pynq-venv)root@pynq$

4. I start the server without sudo

I noticed the python path and pynq path for Z1 image is totally different from that of the image created for TE0802, ofcourse this is aarch64-linus while the former is arm-linux

Could this have any thing in connection?

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 14, 2022, 10:59am UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/8 "2022-01-14T10:59:50Z")

</div>

Also, I want to try version 2.6 any idea on how to get PYNQ rootfs aarch64 v2.6, so I create an img file for TE0802, I only saw rootfs aarch64 v2.6 on the pynq site

---

<div class="post-metadata">

**Author:** ![cathalmccabe](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/cathalmccabe/32/3348_2.png) [@cathalmccabe](https://discuss.pynq.io/u/cathalmccabe)\
**Post date:** [January 14, 2022, 11:13am UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/9 "2022-01-14T11:13:10Z")

</div>

Link:  
[https://bit.ly/pynq\_rootfs\_aarch64\_v2\_6](https://bit.ly/pynq_rootfs_aarch64_v2_6)

Cathal

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 14, 2022, 11:57am UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/10 "2022-01-14T11:57:24Z")

</div>

Hello Cathal,

Thank you, however this is an image file (.img), I am looking for this file as a tar(tar.gz) as a prerequisite for prebuilt images creation of custom board

e.g: focal.aarch64.2.6.0\_2020\_10\_19.tar.gz

that will enable me run this command:  
bash scripts/image\_from\_prebuilt.sh TE0802 xilinx-te0802-2020.1.bsp aarch64 focal.aarch64.2.6.0\_2020\_10\_19.tar.gz

Or is there any other way to generate the required img files for my custom board using bionic.aarch64.2.6.0\_2020\_10\_19.img? N/B: I already have the image.ub, BOOT.BIN and boot.scr for my custom board.

Thank you in anticipation

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [January 14, 2022, 1:39pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/11 "2022-01-14T13:39:10Z")

</div>

The way prebuilt images are formatted has been changed starting in pynq v2.7, previous pynq versions were using .img format. The sdbuild makefile still accepts both .img and .tar.gz as far as I’m aware, if not you could switch the the v2.6 branch of pynq.

Thanks  
Shawn

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [January 14, 2022, 3:36pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/13 "2022-01-14T15:36:23Z")

</div>

After cloning the main github repo `git clone https://www.github.com/XILINX/PYNQ` you can switch to a different branch with `git checkout image_v2.6.0` from inside the repo.

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 14, 2022, 3:40pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/14 "2022-01-14T15:40:47Z")

</div>

Okay let me try that because the current repo of v2.7 is giving this error about the image file

mkdir -p /home/eamicheal/PYNQ/sdbuild/ccache  
sudo rm -fr /home/eamicheal/PYNQ/sdbuild/build/bionic.TE0802  
mkdir /home/eamicheal/PYNQ/sdbuild/build/bionic.TE0802  
(cd /home/eamicheal/PYNQ/sdbuild/build/bionic.TE0802 && sudo tar -xf /home/eamicheal/PYNQ/sdbuild/bionic.aarch64.2.6.0\_2020\_10\_19.img)  
tar: This does not look like a tar archive  
tar: Skipping to next header  
tar: Exiting with failure status due to previous errors  
make: \*\*\* [Makefile:345: /home/eamicheal/PYNQ/sdbuild/build/TE0802.tar.gz] Error 2

Let me try using the v2.6.0 and hope it works

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [January 20, 2022, 5:25pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/15 "2022-01-20T17:25:37Z")

</div>

As an update,

I generated a BSP file (xilinx-zcu104-v2020.1-final.bsp) for TE0802 using the petalinux workflow and also downloaded the board agnostic image file (focal.aarch64.2.6.0\_2020\_10\_19.tar.gz), then copied both into the sdbuild folder.

Thereafter I ran this command:  
bash scripts/image\_from\_prebuilt.sh ZCU104 xilinx-zcu104-v2020.1-final.bsp aarch64 bionic.aarch64.2.6.0\_2020\_10\_19.img

**I got the v2.6.0 image file for TE0802.**

I ran the inference again and this time I successfully deployed a base and simple model and the error ‘No Module called “PYNQ” no longer appears’, Although, when I run some other complex model it get stuck toward the end after writing the bitstream, I am still looking at what could be responsible for this.

I think the initial error “no module called “Pynq” was as a result of the pynq virtual directory of the v2.7.0, which appears at the /usr/local/share/pynq-venv/lib, but that of v2.6.0 appears at the /usr/lib which the DL Compiler stack and rpc environment setup I am using is compatible with or defined to look out for.

Thanks for the support

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [February 14, 2022, 2:35pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/16 "2022-02-14T14:35:33Z")

</div>

I am re-opening this thread because, I still need the features of v2.7 somewhere in my project.

Its known that I am having issues with this no module called pynq because of the venv path in v2.7 which is different from v2.6.

Apart from sourcing the virtual env on the FPGA, I’m I suppose to define a custom Venv on my host PC to check for a new v-environ?

Any idea would be helpful please

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [February 14, 2022, 8:24pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/17 "2022-02-14T20:24:28Z")

</div>

I’m not very well versed in rpc applications, it could be helpful if you shared links to any tutorials or material you’ve been following, to get a better grasp of what is going on.

One solution, because you don’t seem to have trouble running pynq locally, could be to run directly on the device, as discussed on [this post](https://discuss.tvm.apache.org/t/solved-pynq-vta-run-model-locally-on-pynq-z1-instead-of-via-rpc/4336). It might be also worthwhile posting on that forum as well and see if you could get any pointers.

Thanks  
Shawn

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [February 15, 2022, 2:49pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/18 "2022-02-15T14:49:18Z")

</div>

Hi Shawn,

[This tutorial](https://tvm.apache.org/docs/topic/vta/install.html) is what I am following, the part B - Xilinx Pynq FPGA Setup  
I tried on v2.6 and works fyn but on v2.7, I have not got it working

For your [suggested tread](https://discuss.tvm.apache.org/t/solved-pynq-vta-run-model-locally-on-pynq-z1-instead-of-via-rpc/4336), Ive posted an enquiry since last year and yet to receive a reply, however this looks more of working with venv on v2.7 rtaher than rpc.

Someone suggested - If you are using host (e.g., your desktop) and target (your board). Make sure you install Pynq v2.7 on both platforms, Is it possible to install Pynq v2.7 on my host PC?

---

<div class="post-metadata">

**Author:** ![skalade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/skalade/32/686_2.png) [@skalade](https://discuss.pynq.io/u/skalade)\
**Post date:** [February 15, 2022, 11:07pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/19 "2022-02-15T23:07:31Z")

</div>

You might be able to install pynq on a host PC, but I’m not 100% on that.

See this [start\_rpc\_server.sh](https://github.com/apache/tvm/blob/main/apps/vta_rpc/start_rpc_server.sh) file, one thing to try could be to add `source /etc/profile.d/pynq_venv.sh` at the end of that script. Or append the python paths you see after sourcing the virtualenv.

Thanks  
Shawn

---

<div class="post-metadata">

**Author:** ![atopet](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@atopet](https://discuss.pynq.io/u/atopet)\
**Post date:** [February 17, 2022, 2:38pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/20 "2022-02-17T14:38:13Z")

</div>

Hi Shawn,

I tried this on v2.7  
Added these to the [start\_rpc\_server.sh](https://github.com/apache/tvm/blob/main/apps/vta_rpc/start_rpc_server.sh) 1. source /etc/profile.d/pynq\_venv.sh 2. pythonpath (/usr/local/share/pynq-venv/bin/python)

Then as root, I source for and [rpc\_server.py](https://github.com/apache/tvm/blob/main/vta/python/vta/exec/rpc_server.py)

I now have a new errror “ImportError: cannot import name ‘xlnx’ from ‘pynq’”

 ![Screenshot from 2022-02-17 14-54-59](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/9/9f09f0757054282065ac706de94bd41b8bcb0679.png)

I look at the rpc\_server.py and saw these line throwing the error, but same script they works fyn on v2.6  
if env.TARGET == “pynq”:  
from pynq import xlnk  
xlnk.Xlnk().xlnk\_reset()

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [February 17, 2022, 3:18pm UTC](https://discuss.pynq.io/t/no-module-called-pynq/3513/21 "2022-02-17T15:18:55Z")

</div>

@atopet,

xlnk is deprecated in 2.7.0 [Release Austin Release · Xilinx/PYNQ · GitHub](https://github.com/Xilinx/PYNQ/releases/tag/v2.7.0), `pynq.allocate()` is the API you should be using now to allocate buffers.

Mario

[Next page](https://discuss.pynq.io/t/no-module-called-pynq/3513.md?page=2)
