【发布时间】:2021-10-14 08:08:54
【问题描述】:
这是引发错误的代码的 sn-p:
writer=pd.ExcelWriter('C:\\Users\\aji/Curve.xlsx',engine='openpyxl')
if os.path.exists('C:\\Users\\aji/Curve.xlsx'):
os.remove('C:\\Users\\aji/Curve.xlsx')
我收到此错误消息:
PermissionError: [WinError 32] The process cannot access the file because it is being used by
another process: 'C:\\Users\\aji/Curve.xlsx'
我很确定路径中的文件没有打开。是什么导致了这个问题,我该如何解决?
【问题讨论】:
-
什么是完整的回溯?另外,你在用 jupyter 吗?
-
是的,我正在使用 jupyter。
-
您可能运行了另一个打开该文件的单元格。重新启动内核并重试。另外,完成后请务必关闭编写器:
writer.close() -
重启内核并在使用后关闭了写入器——但仍然出现错误。
-
文件是否在excel中打开?
标签: python pandas windows error-handling file-permissions