Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while reading .npy file: parsing header failed: unsupported type O #20

Open
thgngu opened this issue Jul 13, 2018 · 4 comments
Open

Comments

@thgngu
Copy link

thgngu commented Jul 13, 2018

I'm using julia 0.6.1, installed NPZ by Pkg.add("NPZ")

I have a .npy file that created by numpy 1.14.3 on Ubuntu 16.04, Conda 4.4.10.

I get the following error trying to read it in

parsing header failed: unsupported type O

Stacktrace:
 [1] parsedtype(::String) at /opt/anaconda3/share/julia/site/v0.6/NPZ/src/NPZ.jl:135
 [2] parseheader(::String) at /opt/anaconda3/share/julia/site/v0.6/NPZ/src/NPZ.jl:157
 [3] npzreadarray(::IOStream) at /opt/anaconda3/share/julia/site/v0.6/NPZ/src/NPZ.jl:191
 [4] npzread(::String) at /opt/anaconda3/share/julia/site/v0.6/NPZ/src/NPZ.jl:218

Here is my file if you have time to take a look at. It's just a regular 1D, np.float64 array.

@fhs
Copy link
Owner

fhs commented Jul 13, 2018

I think you have the wrong file? That file indeed contains a float64 (<f8) array, which I can load just fine in NPZ. However, you're getting an error about type O, which is the python object type.

Adding support for importing python objects inside julia is not an easy task.

@SilvaEmerson
Copy link

I had the same problem and a get around that by using PyCall, like this:

using PyCall

np = pyimport("numpy")

data = np.load("data.npy", allow_pickle=true)

@zsz00
Copy link
Contributor

zsz00 commented Oct 25, 2019

me too, I had the same problem and a get around that by using PyCall.
npy save a Object type data, load use this allow_pickle=true, is OK.
but NPZ.npzread() is unsupported type O

@bjarthur
Copy link

bjarthur commented Feb 5, 2020

with the PyCall solution above, you then access the variables within an npz file using get(data, :my_variable_name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants