问题
Traceback (most recent call last):
File “D:\project\test_st\retrieval\read_npy.py”, line 4, in
data = np.load(‘mosi0__level_all__pre_vision.npy’)
File “D:\Anaconda\anaconda3\envs\d2l\lib\site-packages\numpy\lib\npyio.py”, line 456, in load
return format.read_array(fid, allow_pickle=allow_pickle,
File “D:\Anaconda\anaconda3\envs\d2l\lib\site-packages\numpy\lib\format.py”, line 795, in read_array
raise ValueError("Object arrays cannot be loaded when "
ValueError: Object arrays cannot be loaded when allow_pickle=False
自从1.16.3版本,allow_pickle=False
是默认的,要么allow_pickle=True
,要么降低numpy版本
解决方法1:allow_pickle=True
将代码修改为allow_pickle=True
import numpy as np
np.load(file, allow_pickle=True)
解决方法2:降低numpy版本
降低numpy<1.16.3
版本,但需要注意你的python
版本为2.7
和3.5-3.7
pip install numpy==1.16.2
Numpy官网:https://numpy.org/doc/stable/reference/generated/numpy.load.html
错误原因:python和numpy版本不兼容
查看我python的版本和numpy的版本
numpy=1.16.1和1.16.2
,与我环境中的python=3.9
不兼容,会出现以下错误:
ModuleNotFoundError: No module named ‘distutils.msvccompiler’
[end of output]- `git clean -xdf` (cleans all files) - `git clean -Xdf` (cleans all versioned files, doesn't touch files that aren't checked into the git repo) Add `--force` to your command to use it anyway if you must (unsupported). [end of output]
note: This error originates from a subprocess, and is likely not a
problem with pip. ERROR: Failed cleaning build dir for numpy Failed
to build numpy ERROR: ERROR: Failed to build installable wheels for
some pyproject.toml based projects (numpy)
会出现下面的提醒与报错: