To replace a page in a given file you can try do the following approach:
- Get the page (the object) that you wanna modify/replace
- Change it (the PyPDF2 return the object itself instead a getter, so, you can change it).
In the code below, I'm adding a "water mark" in my document:
tmp_name = "__tmp.pdf"
output_file = PdfFileWriter()
with open(inFile, 'rb') as f:
# Read the pdf (create a pdf stream)
pdf_original = PdfFileReader(f, strict=False)
# put all buffer in a single file
output_file.appendPagesFromReader(pdf_original)
# create new PDF with water mark
WaterMark._page(fixPage, tmp_name)
# Open the created pdf
with open(tmp_name, 'rb') as ftmp:
# Read the temp pdf (create a pdf stream obj)
temp_pdf = PdfFileReader(ftmp)
for p in range(startPage, startPage+pages):
original_page = output_file.getPage(p)
temp_page = temp_pdf.getPage(0)
original_page.mergePage(temp_page)
# write result
if output_file.getNumPages():
# newpath = inFile[:-4] + "_numbered.pdf"
with open(outFile, 'wb') as f:
output_file.write(f)
os.remove(tmp_name)
My answer is based on this and this
The pdf that I've used

Above you can see the second page (edited page) in my document.