当前位置:网站首页>‘PdfFileWriter‘ object has no attribute ‘stream‘
‘PdfFileWriter‘ object has no attribute ‘stream‘
2022-04-22 05:36:00 【xkxsxkx】
首先借用github上的解答链接
% python3 -m venv venv
% source ./venv/bin/activate
[venv] % pip install pypdf2==1.26.0
[venv] % python test.py
1.26.0
[venv] % pip install pypdf2==1.27.3
[venv] % python test.py
1.27.3
Traceback (most recent call last):
File "test.py", line 39, in
main()
File "test.py", line 35, in main
split(pdf_data, split_info)
File "test.py", line 22, in split
pdf_writer.write(tmp_io)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 480, in write
self._sweepIndirectReferences(externalReferenceMap, self._root)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 572, in _sweepIndirectReferences
self._sweepIndirectReferences(externMap, realdata)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 548, in _sweepIndirectReferences
value = self._sweepIndirectReferences(externMap, value)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 572, in _sweepIndirectReferences
self._sweepIndirectReferences(externMap, realdata)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 548, in _sweepIndirectReferences
value = self._sweepIndirectReferences(externMap, value)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 557, in _sweepIndirectReferences
value = self._sweepIndirectReferences(externMap, data[i])
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 572, in _sweepIndirectReferences
self._sweepIndirectReferences(externMap, realdata)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 548, in _sweepIndirectReferences
value = self._sweepIndirectReferences(externMap, value)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 589, in _sweepIndirectReferences
newobj = self._sweepIndirectReferences(externMap, newobj)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 548, in _sweepIndirectReferences
value = self._sweepIndirectReferences(externMap, value)
File "/home/dst/Desktop/pypdf2/venv/lib/python3.8/site-packages/PyPDF2/pdf.py", line 575, in _sweepIndirectReferences
if data.pdf.stream.closed:
AttributeError: 'PdfFileWriter' object has no attribute 'stream'
可以看到在版本为1.26.0时,可以正常运行,而默认安装的版本一般可能会是1.27以上,就会报错
所以要解决这个问题就只用
pip install pypdf2==1.26.0
之后就可以正常运行了
版权声明
本文为[xkxsxkx]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_38836770/article/details/124315644
边栏推荐
- List中set方法和add方法的区别
- 随机字符串工具类RandomStringUtils详解
- Write a program to automatically generate the two-color ball number of welfare lottery with MATLAB
- 雷达设备(贪心)
- [fedmd, a heterogeneous FL training method using model distillation] fedmd: heterogeneous federated learning via model distillation
- 可重入锁卖票示例
- 元注解(注解的注解)
- 导弹拦截问题(dp,dilworth定理)
- 09-Redis之IO多路复用
- imencode 源码解读
猜你喜欢
随机推荐
MySQL transaction
数据库迁移遇到的问题和解决方案
数据已删除,又重新出现的问题排查
再见2020,2021我来了
"Huawei Cup" programming competition for freshmen of Wuhan University J. hearsay file
TP50、TP90、TP99的理解和使用
我常用的开发软件
提高工作效率的利器
10.Advance Next Round
雷达设备(贪心)
关于form表单点击submit按钮后,页面自动刷新的问题解决
Pratique du langage C (2) - - mise en oeuvre de l'addition polynomiale par liste liée
LockSupport.park和unpark,wait和notify
AcWing 836. 合并集合(并查集)
最长上升子序列(lis)
9.Life, the Universe, and Everything
Enumerations and lambda expressions
Force buckle - 322 Change
线性筛法(素数筛)
OBDUMPER常用导出命令









