tags: Error analysis PyPDF2 python
I found a problem when I was consolidated today, and I couldn't delete the source file after I merged the PDF file.
Permissionerror: [Winerror 32] Another program is using this file, the process is unable to access
This error has occurred, and I tried to delete the source file manually, and the file has been opened by Python and the prompt that cannot be operated.
Lite mean, this file has been occupied, you can't access him.
def merge_pdf(name,file_all,target_path):
total=PdfFileWriter()
totalPages=0
for pdf_file in file_all:
print(pdf_file)
# Read PDF files
pic=open(pdf_file,'rb')
input_pdf=PdfFileReader(pic)
# Get the number of pdf total pages
pagecount=input_pdf.getNumPages()
print(pagecount)
totalPages+=pagecount
# Traversing each PDF file
for iPage in range(pagecount):
#
total.addPage(input_pdf.getPage(iPage))
#pic.close()
#os.remove(pdf_file)
Print (Totalpages, 'Sharing PDF file merge ...')
target_name=name+'.pdf'
new=os.path.join(target_path,target_name)
with open(new,'wb') as outputfile:
total.write(outputfile)
The reason is that I didn't turn it off after reading the feeding file, causing him to have a cache.
I tried to turn off the delete operation in the comment location, I successfully deleted the source PDF file.
But I am surprised to find that the merged documents are all blank.
It turned out that I deleted the source file, causing no data when writing.
I am inserting a write operation before turning off.
The purpose of deleting the source file after successfully reaching the merger.
Problem Description: Python3.7, using the library image inside PIL just wants to get the length and wide of the picture Newspaper is wrong D:\Python37-32\python.exe D:/pyFile/python_script/img_read.py...
When making image processing, I used three modules OS, PIL, CV2. I encountered a bug who plagued one morning, I investigated several resource monitor ~~~, bug as follows: Description of Requirement: 1...
Background & Issue After the disk is finished, the WSL cannot be started. Tip "Another program is using this file, the process is unable to access." solve Restarting and resource managem...
content surroundings Phenomenon reason Solution Problem correction delete file log refer to surroundings Windows2012 R2 kafka_2.12-2.3.0 Phenomenon reason Kafka Prof...
Article catalog Foreword First, solve the idea Second, the answer 3. Reference documentation Foreword Deploying an ASP.NET Core project on IIS, an error that occupies the process during the update Fir...
Run from Liao Xuefeng tutorialDistributed process Example, PermissionError: [WinError 5] when running in the windows environment Error log: Running cmd and powershell with administrator privileges sti...
problem : Today to start Kafka failure Problem Description: When you start Kafka, then view the log, the wrong point is as follows: Originally: If this problem, I haven't found specific reasons, and t...
forward from:Gentle and easy to light - windows pip install python module error summary Foreword: Put python these daysversion upgradeAfter that, I found that many of the pip installation modules were...
cookie acquisition Traceback (most recent call last): File “C:\Users\15300\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py”, line 76, in start...
An error "PermissionError: [WinError 5] Access Denied" occurred during pip installation. Solution: 1. Cut to the directory shown by the arrow, and everyone will be slightly different. This &...