hickle NameError: name 'file' is not defined

柔情痞子 提交于 2021-02-10 07:25:29

问题


please explain to me why this error getting for me. I have install python 3.5 in ubuntu

import os
import hickle as hkl
import numpy as np
array_obj = np.ones(32768, dtype='float32')
hkl.dump(array_obj, 'test.hkl', mode='w')

the result is

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\hickle.py", line 308, in dump
    h5f = file_opener(file_obj, mode, track_times)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\hickle.py", line 148, in file_opener
    if isinstance(f, file):
NameError: name 'file' is not defined

回答1:


Hickle doesn't support Python3 (it uses file() function not supported in Python3), but you can find modified version on GitHub, or just use Python2.




回答2:


As one of the main developers of hickle: 3 years ago, it indeed did not support Python 3 yet. Nowadays on the other hand, it works just fine (and, in fact, has dropped support for Python 2.7 by now).



来源:https://stackoverflow.com/questions/48276174/hickle-nameerror-name-file-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!