问题
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