Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3.8.7环境,运行报错 #20

Open
NewTrees opened this issue Jul 17, 2024 · 3 comments
Open

Python3.8.7环境,运行报错 #20

NewTrees opened this issue Jul 17, 2024 · 3 comments

Comments

@NewTrees
Copy link

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)

@renoyuan
Copy link
Owner

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

@NewTrees
Copy link
Author

更新到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)

@ssh-buanshishi
Copy link

根据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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants