我是 PyMuPDF 的维护者。你的配置是什么?我刚刚使用 v1.18.13 在 Windows 和 Linux 上尝试了您的代码,并且可以正常工作。
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fitz
>>> fitz.version
('1.18.13', '1.18.0', '20210505063222')
>>> doc=fitz.open("v110-changes.pdf")
>>> page=doc[0]
>>> pix=page.get_pixmap()
>>> b=pix.tobytes()
>>>
视窗:
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import fitz
>>> fitz.version
('1.18.13', '1.18.0', '20210505063222')
>>> doc=fitz.open("v110-changes.pdf")
>>> page=doc[0]
>>> pix=page.get_pixmap()
>>> b = pix.tobytes()
>>>