在使用numpy模块将图片转化为数组:
img = np.asarray(image)
之后让数组的读写模式设置成True时:
img.flags.writeable = True
报错:cannot set WRITEABLE flag to True
问题原因:
numpy版本与pytables的最新版本不兼容(请参阅 https://github.com/PyTables/PyTables/blob/v3.4.4/tables/hdf5extension.pyx#L2155 ),但pytables团队尚未发布固定版本:https://github.com/PyTables/PyTables/issues/719
我找到解决这个问题的唯一方法是降级numpy。
把numpy降到1.15版本,且python版本应该是3.5或3.7,3.6可能也不行。
python -m pip install numpy==1.15
问题解决。