使用np.load(使用Spyder)后关闭文件 [英] Closing a file after using np.load (using Spyder)
问题描述
我正在加载文件:
a= np.load('myfile.npz')
然后使用a
过一会儿,我重新生成了myfile.npz
(在远程计算机上).
After a while I regenerate myfile.npz
(on a remote machine).
当我尝试从远程计算机跨文件复制(使用WinSCP)时,它失败,报告:
When I attempt to copy the file across (using WinSCP) from the remote machine it fails, reporting:
System Error. Code: 32.
The process cannot access the file because it is being used by another process.
我已经尝试过了:
>>> a.fid
<open file 'myfile.npz', mode 'rb' at 0x058A78B8>
>>> a.fid.close()
>>> a.fid
<closed file 'myfile.npz', mode 'rb' at 0x058A78B8>
但是,文件复制仍然失败.
However, the file copy still fails.
如果我关闭python解释器,则复制成功.
If I close the python interpreter, the copy succeeds.
是什么原因导致此问题?我是否需要先关闭myfile.npz
(我曾经认为这是自动处理的)?如果是这样,我该怎么办?
What is causing this porblem? Do I need to close myfile.npz
(I had thought this was handled automatically) first? If so, how do I do it?
我正在Win7的Spyder IDE中使用python控制台.
I'm using a python console with in the Spyder IDE on Win7.
推荐答案
I have found that using del
also works:
del a
这篇关于使用np.load(使用Spyder)后关闭文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!