XlsxWriter: unable to close(); saves a corrupted workbook
import xlsxwriter
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello world')
workbook.close()
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:\Users\DOUGHE~1.ROS\AppData\Local\Temp\tmpnpp39a_c’
I was able to write excel files yesterday; today my day began with this issue and I was not able to resolve. I was hoping someone here may be of assistance.
If I run workbook.close() again, I do not receive the error, but the .xlsx file does not open and says it is corrupted.
I'm not sure what happened. I may have have closed/exited the program incorrectly. I've read of the importance of using workbook.close(), did I create a 'write to excel ghost' living in the purgatory of my temp folder? This issue now extends to pandas .to_excel() as well. I am able to write to csv.
I've restarted, reinstalled anaconda +packages, deleted all the tmp files in the temp folder, however I still receive this error. Any help would be greatly appreciated. Thank you.
windows 10
python 2.7, 3.6, 3.7 (I had base install of anaconda py 2.7, with an additional environment of 3.6. Reinstalled anaconda with python 3.7, 64bit. Issue happened with all three)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (10 by maintainers)
The file doesn’t appear to be open in Excel. At least, excel doesn’t seem to be running in task manager and I’ve not opened it. Here is the trace of the error: