Getting an error when setting array value to NetworkTables4

I have been working on some code in Python with RobotPy (version 2023.4.3) and have been stuck on debugging an error for the past few days when trying to push a double array (List[float]) to NetworkTables4 on a test board.

Traceback (most recent call last):
  File "/home/orangepi/test.py", line 15, in <module>
    publisher.set([129391.1234234, 123984.324239])
MemoryError: std::bad_alloc

I have been unable to recreate this issue in Windows or MacOS systems, in which both my minimal and full Python code have worked without fault. This issue occurs regardless of the array type, having tried all the NetworkTables array publishers. Single double, float, int, etc. publishers work without fault.

I’ve written a minimal test script shown below:

import ntcore

instance = ntcore.NetworkTableInstance.getDefault()
instance.setServerTeam(694)
instance.setServer("10.6.94.2", ntcore.NetworkTableInstance.kDefaultPort4)
instance.startClient4("694_client")
table = instance.getTable("/output")

publisher = table.getDoubleArrayTopic("test").publish()

publisher.set([129391.1234234, 123984.324239])

I have exhausted all debugging methods that I have been able to think of with no success. Any help or guidance would be greatly appreciated. Thank you in advance.

What distro are you using, and how did you install pyntcore?

If you compiled pyntcore yourself, that’s the problem. You need to install our wheel – see [BUG]: MemoryError when publishing arrays · Issue #40 · robotpy/pyntcore · GitHub for a similar issue that someone else had.

Thank you for your response.

OS: Orange Pi 5 Ubuntu Server 5.10.110

I used the following command to install the wheel, which I found in the RobotPy documentation on installing pyntcore:

pip3 install --find-links https://tortall.net/~robotpy/wheels/2023/raspbian/ pyntcore

Hm, should have worked correctly, what version of Python are you using? Did it install instantly or take a long time? If it took a long time then it would have recompiled the wheel…

You might reinstall, adding --only-binary :all: to the command line to see if that addresses it.

1 Like

I’m using Python 3.10.12. I did notice that it was taking a while to install when I initially did it which I thought was a bit suspicious, but didn’t think too much about it.

I just got into the lab and reinstalled pyntcore with the --only-binary :all: flag and it’s working perfectly fine now.

This seems like something to add to the documentation so that other teams in the future won’t get stuck on the same issue. Thank you for your help.