Import error - no module named numpyio

Does anyone know how to solve this error?

Exception Type: ImportError Exception Value: No module named numpyio 

See my python code, my import:

 from scipy.io.numpyio import fwrite, fread 

Can you help me?

+4
source share
3 answers

This is due to the fact that the scipy.io.numpyio module was removed somewhere in SciPy 0.7 (see, for example, this thread ). On the SciPy Cookbook I / O page, you can use the numpy.fromfile and numpy.nadarray.tofile functions numpy.nadarray.tofile (see the Raw binary heading).

+4
source

While numpy.ndarray.fromfile() allows you to specify a binary format for reading (for example, 'f' for float), the .tofile() function does not have such binary options. This is a very inconvenient inconsistency for those of us who need to write binaries in a specific format to read other software. Unfortunately, this issue seems to be ignored by the developer community, as there seems to be no open ticket.

I created a simple replace function using an array module. The main code looks something like this:

 def fwrite(filename, formatstring, ndarray): arr = array.array(formatstring, ndarray.flatten()) f = open(filename, 'w') arr.tofile(f) f.close() 

While this is working. Obviously this can / should be embellished with bugs, etc.

+3
source

From the archives :

The I / O functions for numpy arrays are moved to numpy where they were made, or removed when they provided duplicate functions. Use numpy.load and numpy.save to read arrays of letters in numpy.npy format, loadtxt / savetxt for ascii.

+1
source

Source: https://habr.com/ru/post/1412994/


All Articles