easyofd icon indicating copy to clipboard operation
easyofd copied to clipboard

Python3.8.7环境,运行报错

Open NewTrees opened this issue 1 year ago • 3 comments

Traceback (most recent call last): File "d:/Users/Yum/Desktop/ofdtest.py", line 1, in from easyofd import ofd2pdf File "D:\ProgramData\PythonInstall\lib\site-packages\easyofd_init_.py", line 1, in from .ofd import OFD File "D:\ProgramData\PythonInstall\lib\site-packages\easyofd\ofd.py", line 16, in import fitz File "D:\ProgramData\PythonInstall\lib\site-packages\fitz_init_.py", line 2, in from pymupdf import * File "D:\ProgramData\PythonInstall\lib\site-packages\pymupdf_init_.py", line 29, in from . import extra File "D:\ProgramData\PythonInstall\lib\site-packages\pymupdf\extra.py", line 10, in from . import _extra ImportError: cannot import name 'extra' from partially initialized module 'pymupdf' (most likely due to a circular import) (D:\ProgramData\PythonInstall\lib\site-packages\pymupdf_init.py)

NewTrees avatar Jul 17 '24 10:07 NewTrees

看着像是其他依赖的原因,你先试下更新python 到3.11 看看?

renoyuan avatar Jul 17 '24 12:07 renoyuan

更新到3.11.6也是这个错误:Traceback (most recent call last): File "d:\Users\Yum\Desktop\ofdtest.py", line 1, in from easyofd import ofd2pdf File "D:\ProgramData\PythonInstall\Lib\site-packages\easyofd_init_.py", line 1, in from .ofd import OFD File "D:\ProgramData\PythonInstall\Lib\site-packages\easyofd\ofd.py", line 16, in import fitz File "D:\ProgramData\PythonInstall\Lib\site-packages\fitz_init_.py", line 2, in from pymupdf import * File "D:\ProgramData\PythonInstall\Lib\site-packages\pymupdf_init_.py", line 29, in from . import extra File "D:\ProgramData\PythonInstall\Lib\site-packages\pymupdf\extra.py", line 10, in from . import _extra ImportError: cannot import name 'extra' from partially initialized module 'pymupdf' (most likely due to a circular import) (D:\ProgramData\PythonInstall\Lib\site-packages\pymupdf_init.py)

NewTrees avatar Jul 17 '24 13:07 NewTrees

根据PyMuPDF:https://pymupdf.readthedocs.io/en/latest/tutorial.html#note-on-the-name-fitz 如果同时安装PyMuPDF和老的库fitz,可能将引发import错误:

Note on the Name fitz Old versions of PyMuPDF had their Python import name as fitz. Newer versions use pymupdf instead, and offer fitz as a fallback so that old code will still work.

The reason for the name fitz is a historical curiosity:

The original rendering library for MuPDF was called Libart.

“After Artifex Software acquired the MuPDF project, the development focus shifted on writing a new modern graphics library called “Fitz”. Fitz was originally intended as an R&D project to replace the aging Ghostscript graphics library, but has instead become the rendering engine powering MuPDF.” (Quoted from Wikipedia).

Note

Use of legacy name fitz can fail if defunct pypi.org package fitz is installed; see Problems after installation.

所以试试看将PyMuPDF和fitz同时卸载掉,然后重新安装PyMuPDF

@renoyuan 大佬,是时候考虑引入新的库名称PyMuPDF了,我建议将所有的fitz换为PyMuPDF

ssh-buanshishi avatar Sep 21 '24 02:09 ssh-buanshishi