# Error building Pymodbus

**URL:** <https://forum.legato.io/t/error-building-pymodbus/5913>\
**Category:** Legato Linux distribution (Yocto project)\
**Created:** [July 29, 2021, 7:34am UTC](https://forum.legato.io/t/error-building-pymodbus/5913 "2021-07-29T07:34:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [July 29, 2021, 7:34am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/1 "2021-07-29T07:34:56Z")

</div>

Facing error building pymodbus:

Initialising tasks: 100% |#######################################| Time: 0:00:00  
NOTE: Executing SetScene Tasks  
NOTE: Executing RunQueue Tasks  
ERROR: pymodbus-2.5+gitAUTOINC+731b080df0-r0 do\_compile: python setup.py build execution failed.  
ERROR: pymodbus-2.5+gitAUTOINC+731b080df0-r0 do\_compile: Function failed: do\_compile (log file is located at /home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/pymodbus/2.5+gitAUTOINC+731b080df0-r0/temp/log.do\_compile.15160)  
ERROR: Logfile of failure stored in: /home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/pymodbus/2.5+gitAUTOINC+731b080df0-r0/temp/log.do\_compile.15160  
Log data follows:  
| DEBUG: Executing shell function do\_compile  
| Traceback (most recent call last):  
| File “setup.py”, line 28, in   
| from pymodbus.utilities import IS\_PYTHON3  
| File “/home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/pymodbus/2.5+gitAUTOINC+731b080df0-r0/git/pymodbus/utilities.py”, line 8, in   
| from pymodbus.compat import int2byte, byte2int, IS\_PYTHON3  
| File “/home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/pymodbus/2.5+gitAUTOINC+731b080df0-r0/git/pymodbus/compat.py”, line 15, in   
| import six  
| ImportError: No module named six  
| ERROR: python setup.py build execution failed.  
| WARNING: /home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/pymodbus/2.5+gitAUTOINC+731b080df0-r0/temp/run.do\_compile.15160:1 exit 1 from ‘exit 1’  
| ERROR: Function failed: do\_compile (log file is located at /home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/pymodbus/2.5+gitAUTOINC+731b080df0-r0/temp/log.do\_compile.15160)  
ERROR: Task (/home/pankaj/Documents/wp76xx-linuxsrc-rel13.1/yocto/meta-openembedded/meta-python/recipes-devtools/python/pymodbus\_2.5.2.bb:do\_compile) failed with exit code ‘1’  
NOTE: Tasks Summary: Attempted 655 tasks of which 654 didn’t need to be rerun and 1 failed.

Python six is already installed in the image though local.conf  
IMAGE\_INSTALL\_append\_pn-mdm9x28-image-minimal = " python-six python-paho-mqtt"

pymodbus recipe is created using the recipetool in Bitbake command:

recipetool -d create -o yocto/meta-openembedded/meta-python/recipes-devtools/python/pymodbus\_2.5.2.bb [GitHub - riptideio/pymodbus: A full modbus protocol written in python](https://github.com/riptideio/pymodbus.git)

Attached is the recipe which is giving error .

looking for any modifications required to build the recipe  
[pymodbus\_2.5.2.bb](https://forum.legato.io/uploads/short-url/pYCMBJbSgZAxozx6Qv6bLFgrGg.bb) (4.1 KB)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [July 29, 2021, 7:40am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/2 "2021-07-29T07:40:00Z")

</div>

how about adding the following recipe in  
./meta-swi/meta-swi-mdm9x28/recipes-core/images/mdm9x28-image.inc

IMAGE\_INSTALL\_append =" pymodbus"

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [July 29, 2021, 11:00am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/3 "2021-07-29T11:00:44Z")

</div>

@jyijyi

Will try the suggestion but I think it should not make a difference as "IMAGE\_INSTALL\_append\_pn- **mdm9x28-image-minimal** mentions the correct target to add the recipe.

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [July 29, 2021, 11:11am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/4 "2021-07-29T11:11:49Z")

</div>

In case if python six is not installed I believe Rdepends should take care of providing a error but it doesn’t. Below is the RDEPENDS from the recipe:

RDEPENDS\_${PN} += “python-2to3 python-contextlib python-core python-crypt python-distutils python-io python-json python-lang python-logging python-math python-netserver python-setuptools python-shell python-six python-threading python-unittest”

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/a/ac299966f95376cf858fcce4e8d14b81cf6715e0.png)

So ideally I should have got a build error with no provider for Python-six , but rather I see error reported on import statement in compat.py

I believe may have to add some tasks intially before compiling pymodbus

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [July 29, 2021, 2:52pm UTC](https://forum.legato.io/t/error-building-pymodbus/5913/5 "2021-07-29T14:52:08Z")

</div>

I found that I cannot add  
IMAGE\_INSTALL\_append =" python-pymodbus"

it seems it is not officially supported.

---

<div class="post-metadata">

**Author:** ![billzhou](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@billzhou](https://forum.legato.io/u/billzhou)\
**Post date:** [July 30, 2021, 2:10am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/6 "2021-07-30T02:10:58Z")

</div>

Hi Pankaj,

If you are trying to make a Modbus master, maybe have a quick read of this wiki link,  
[https://bitbucket.org/m2mconnectivity/pyrtedoc/wiki/Modbus%20master](https://bitbucket.org/m2mconnectivity/pyrtedoc/wiki/Modbus%20master)  
If it helps, here is the home of wiki which tries to include Python3 and popular modules(such as pyserial, requests) without rebuilding Linux image for Legato modules/FX30s,  
[m2mconnectivity / PyRTEdoc / wiki / Home — Bitbucket](https://bitbucket.org/m2mconnectivity/pyrtedoc/wiki/Home)

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [July 30, 2021, 2:54am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/7 "2021-07-30T02:54:28Z")

</div>

@billzhou

Yes looking for Modbus master this one looks to be helpful the implementation seems to be based on Minimal Modbus which supports only RTU any suggestions for modbus TCP.

---

<div class="post-metadata">

**Author:** ![billzhou](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@billzhou](https://forum.legato.io/u/billzhou)\
**Post date:** [July 30, 2021, 9:06am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/8 "2021-07-30T09:06:18Z")

</div>

Hi Pankaj,

Here pls find the guide on how to install Python modules without rebuilding image and it uses PyModbus as example,  
[m2mconnectivity / PyRTEdoc / wiki / Install a Python module — Bitbucket](https://bitbucket.org/m2mconnectivity/pyrtedoc/wiki/Install%20a%20Python%20module)

Hope it helps.

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 4, 2021, 5:29am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/9 "2021-08-04T05:29:11Z")

</div>

@billzhou

Can you let me know where do we get the pyrte application?

Thanks

Pankaj Sant

---

<div class="post-metadata">

**Author:** ![billzhou](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@billzhou](https://forum.legato.io/u/billzhou)\
**Post date:** [August 4, 2021, 6:41am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/10 "2021-08-04T06:41:48Z")

</div>

Hi Pankaj,

The download page of PyRTE looks not ready. If you’d need it now, please message me your email, with your FX30/WP model and firmware version, I’d be happy to arrange you the installers.

---

<div class="post-metadata">

**Author:** ![Pankaj](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/pankaj/32/1317_2.png) [@Pankaj](https://forum.legato.io/u/Pankaj)\
**Post date:** [August 4, 2021, 7:14am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/11 "2021-08-04T07:14:09Z")

</div>

@billzhou ,

you can email me the installers for wp76 rel13.1 firmware on [pankajrsant@gmail.com](mailto:pankajrsant@gmail.com)

---

<div class="post-metadata">

**Author:** ![billzhou](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@billzhou](https://forum.legato.io/u/billzhou)\
**Post date:** [April 12, 2022, 12:37am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/12 "2022-04-12T00:37:50Z")

</div>

The free download page for PyRTE is here if any one needs it,

> **[M2M FX30 PyRTE Python solution](https://www.m2mconnectivity.com.au/products-2/m2m-fx30-pyrte-python-solution/)**
>
> M2M Connectivity has made Sierra Wireless’ iconic FX30 Programmable IoT Gateway available with a new Python Runtime Environment (PyRTE) – developed in Australia

Currently it supports FX30 Cat M1 and WP7702. Firmware Release 14.

---

<div class="post-metadata">

**Author:** ![yuser](https://avatars.discourse-cdn.com/v4/letter/y/ed8c4c/32.png) [@yuser](https://forum.legato.io/u/yuser)\
**Post date:** [June 24, 2022, 12:08pm UTC](https://forum.legato.io/t/error-building-pymodbus/5913/13 "2022-06-24T12:08:42Z")

</div>

Hi, I have some similar issue, as I am trying to add Pymodbus to my image as a library I get the following error as building:

```auto
ERROR: python3-pymodbus-2.5.3-r0 do_compile: 'python3 setup.py build ' execution failed.
ERROR: python3-pymodbus-2.5.3-r0 do_compile: Execution of '/home/usr/reterminal-yocto/build/tmp/work/aarch64-poky-linux/python3-pymodbus/2.5.3-r0/temp/run.do_compile.949277' failed with exit code 1
ERROR: Logfile of failure stored in: /home/usr/reterminal-yocto/build/tmp/work/aarch64-poky-linux/python3-pymodbus/2.5.3-r0/temp/log.do_compile.949277
Log data follows:
| DEBUG: Executing shell function do_compile
| Traceback (most recent call last):
| File "setup.py", line 28, in <module>
| from pymodbus.utilities import IS_PYTHON3
| File "/home/usr/reterminal-yocto/build/tmp/work/aarch64-poky-linux/python3-pymodbus/2.5.3-r0/pymodbus-2.5.3/pymodbus/utilities.py", line 8, in <module>
| from pymodbus.compat import int2byte, byte2int, IS_PYTHON3
| File "/home/usr/reterminal-yocto/build/tmp/work/aarch64-poky-linux/python3-pymodbus/2.5.3-r0/pymodbus-2.5.3/pymodbus/compat.py", line 15, in <module>
| import six
| ModuleNotFoundError: No module named 'six'
| ERROR: 'python3 setup.py build ' execution failed.
| WARNING: exit code 1 from a shell command.
| ERROR: Execution of '/home/usr/reterminal-yocto/build/tmp/work/aarch64-poky-linux/python3-pymodbus/2.5.3-r0/temp/run.do_compile.949277' failed with exit code 1
ERROR: Task (/home/jprobst/TUTO_PROPRES/reterminal-yocto/layers/meta-coperametrix-cm4_gui/recipes-modbustcp/modbustcp/python3-pymodbus_2.5.3.bb:do_compile) failed with exit code '1'

```

Here is my python3-Pymodbus\_version.bb file:

```auto
SUMMARY = "A fully featured modbus protocol stack in python"
HOMEPAGE = "https://github.com/riptideio/pymodbus/"
AUTHOR = "Galen Collins <bashwork@gmail.com>"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=2c2223d66c7e674b40527b5a4c35bd76"

SRC_URI = "https://files.pythonhosted.org/packages/fe/a9/f98aadfcb8d0a34326be68a06a72cc60e04139e8f4fd17633972f8af3b4c/pymodbus-2.5.3.tar.gz"
SRC_URI[md5sum] = "28e8ac7f84adace83319d3733e00dee8"
SRC_URI[sha256sum] = "5ef68c1a109bdb467c830ef003ef2db6494349a5248e4af946fe21c9eefe7e74"

S = "${WORKDIR}/pymodbus-2.5.3"

RDEPENDS_${PN} += "python3-six python3-pyserial"

inherit setuptools3

```

I searched for a long time and have no clue where this error could come from as even when I manually Image\_install\_append six, it still says that I cannot be found. I am not really used to building yocto images yet so I would be really grateful if you could help me understand what I missmade

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 25, 2022, 1:29am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/14 "2022-06-25T01:29:44Z")

</div>

Hi @billzhou , can you share your bb file

---

<div class="post-metadata">

**Author:** ![billzhou](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@billzhou](https://forum.legato.io/u/billzhou)\
**Post date:** [June 25, 2022, 2:31am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/15 "2022-06-25T02:31:13Z")

</div>

@jyijyi I don’t have a bb file for PyModbus but I can try to give a fix.  
@yuser  
Can you please try to add below line in you bb and give it a go?  
DEPENDS += “python3-six-native”

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 25, 2022, 3:53am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/16 "2022-06-25T03:53:42Z")

</div>

I just found that we need to add

```auto

inherit python3native

DEPENDS += "python3-six-native"

```

Here is my bb file and I can make the yocto image:  
[python3-pymodbus\_2.5.3.bb](https://forum.legato.io/uploads/short-url/4Vxqt8x33Zo2FUZQbOYq4tgFmTh.bb) (700 Bytes)

---

<div class="post-metadata">

**Author:** ![yuser](https://avatars.discourse-cdn.com/v4/letter/y/ed8c4c/32.png) [@yuser](https://forum.legato.io/u/yuser)\
**Post date:** [June 25, 2022, 12:28pm UTC](https://forum.legato.io/t/error-building-pymodbus/5913/17 "2022-06-25T12:28:47Z")

</div>

Hi @billzhou @jyijyi I added your lines

```auto
inherit python3native
DEPENDS += "python3-six-native"

```

And it also worked fine for me thanks!  
Do you perhaps have an idea as to why we need to add theses?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 25, 2022, 12:36pm UTC](https://forum.legato.io/t/error-building-pymodbus/5913/18 "2022-06-25T12:36:04Z")

</div>

you can see these two webpages:

> <https://stackoverflow.com/questions/66600264/how-to-invoke-a-python-module-in-yocto-bitbake-recipe>

[https://www.yoctoproject.org/pipermail/yocto/2018-March/040193.html](https://www.yoctoproject.org/pipermail/yocto/2018-March/040193.html)

---

<div class="post-metadata">

**Author:** ![elmanju07](https://avatars.discourse-cdn.com/v4/letter/e/b5e925/32.png) [@elmanju07](https://forum.legato.io/u/elmanju07)\
**Post date:** [June 9, 2025, 9:07am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/19 "2025-06-09T09:07:58Z")

</div>

hi @jyijyi

Can i know how to add the MQtt package and build the Yocto image

IMAGE\_INSTALL\_append =" MQTT-clientservices" like this and build the Image

and flash the .cwe file to the device

Thanks and Regards  
Manju

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 9, 2025, 9:27am UTC](https://forum.legato.io/t/error-building-pymodbus/5913/20 "2025-06-09T09:27:18Z")

</div>

how about using mosquitto?

> **[mqttClient Service Connect error?](https://mangoh.discourse.group/t/mqttclient-service-connect-error/9093/87)**
>
> I tried, but unfortunately this is not the solution either. However, I noticed another thing. I have Mosquitto server installed on windows of another PC and from my Ubuntu I can ping (seeing the connection attempt on the other side): But if I...

> **[OpenEmbedded Layer Index - mosquitto](https://layers.openembedded.org/layerindex/recipe/56181/)**

Or you can use python:

> [@FX30s LTE \[WP7702\] Addition of python recipes](https://forum.legato.io/t/fx30s-lte-wp7702-addition-of-python-recipes/4896/2):
>
> 1.download the yocto source and go to ./meta-swi/meta-swi-mdm9x28/recipes-core/images/mdm9x28-image.inc 2.add the following line: IMAGE\_INSTALL\_append = " python python-paho-mqtt" 3.go to ./meta-swi/meta-swi-mdm9x28/conf/machine/swi-mdm9x28.conf change UBI\_ROOTFS\_SIZE ?= “48MiB” For the python recipes, you can see [https://layers.openembedded.org/layerindex/branch/morty/layer/meta-python/](https://layers.openembedded.org/layerindex/branch/morty/layer/meta-python/)

[Next page](https://forum.legato.io/t/error-building-pymodbus/5913.md?page=2)
