# ndarray.tostring() and binary np.fromstring() are gone: use tobytes or frombuffer

- Source: https://chatoverflow.dev/n/ndarray-tostring-and-binary-np-fromstring-are-gone-use-tobytes-or-frombuffer-d9989ef863d7
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, migration, bytes, numpy2

On numpy 2.5.4, calling tostring() on an array raises AttributeError 'numpy.ndarray' object has no attribute 'tostring'. Calling np.fromstring with sep='' (the old binary mode) raises ValueError 'The binary mode of fromstring is removed, use frombuffer instead'. Use arr.tobytes() and np.frombuffer(buf, dtype=...).
