# Cannot get python node to work

**URL:** <https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578>\
**Category:** Developing Nodes\
**Created:** [30 September 2020 15:15 UTC](https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578 "2020-09-30T15:15:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lchtbruno](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@lchtbruno](https://discourse.nodered.org/u/lchtbruno)\
**Post date:** [30 September 2020 15:15 UTC](https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578/1 "2020-09-30T15:15:19Z")

</div>

I installed the node-red-contrib-python-function using

```auto
npm install -g node-red-contrib-python-function

```

and the package was added successfully.

However, if I try to use the python node, I get an error:

> File "C:\Python38\lib\json\__init_\_.py", line 343, in loads  
> s = s.decode(detect\_encoding(s), 'surrogatepass')  
> File "C:\Python38\lib\encodings\utf\_32\_le.py", line 11, in decode  
> return codecs.utf\_32\_le\_decode(input, errors, True)  
> UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 16-19: code point not in range(0x110000)

The JSON of my Node-RED project is extremely simple

> [{"id":"7bc803fa.fe25ac","type":"tab","label":"1","disabled":false,"info":""},{"id":"d3811b80.53c9e8","type":"inject","z":"7bc803fa.fe25ac","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" { "id": "datapoint1", "value": "124.6215", "timestamp": "1601477603842888960" }","payloadType":"json","x":240,"y":180,"wires":[["de1f02dd.008a9"]]},{"id":"de1f02dd.008a9","type":"python-function","z":"7bc803fa.fe25ac","name":"","func":"\nreturn msg","outputs":1,"x":490,"y":180,"wires":[["2b9229e3.b17286"]]},{"id":"2b9229e3.b17286","type":"debug","z":"7bc803fa.fe25ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":780,"y":180,"wires":}]

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [30 September 2020 15:53 UTC](https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578/2 "2020-09-30T15:53:06Z")

</div>

Have you asked the contrib node author?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 September 2020 16:27 UTC](https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578/3 "2020-09-30T16:27:57Z")

</div>

I think others have had problems with that node, the solution is often to use an exec node instead.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [1 October 2020 19:05 UTC](https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578/4 "2020-10-01T19:05:51Z")

</div>

Or... add MQTT to your python script so it talks to NR in a common method of communication, but it all depends on what the python script is doing, if this is a reasonable option. I have a lot of existing python that I would rather not just replace in NR. So I added MQTT support to much of my python, which made integration of python results into NR, just about painless.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 November 2020 19:06 UTC](https://discourse.nodered.org/t/cannot-get-python-node-to-work/33578/5 "2020-11-30T19:06:01Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
