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

Unable to use fitz with python 3.8 #523

Closed
akjanik opened this issue Jun 3, 2020 · 9 comments
Closed

Unable to use fitz with python 3.8 #523

akjanik opened this issue Jun 3, 2020 · 9 comments
Assignees
Labels
not a bug not a bug / user error / unable to reproduce

Comments

@akjanik
Copy link

akjanik commented Jun 3, 2020

Describe the bug (mandatory)

Trying to run python script that have import fitz cause an error if used with virtualenv with python 3.8.

To Reproduce (mandatory)

Create virtualenv using python 3.8.
pip install pymupdf
add import fitz at the beginning of the file
observe stacktrace

Traceback (most recent call last):
  File "process.py", line 80, in <module>
    main()
  File "process.py", line 56, in main
    import fitz
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/fitz/__init__.py", line 1, in <module>
    from frontend import *
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/frontend/__init__.py", line 1, in <module>
    from .events import *
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/frontend/events/__init__.py", line 1, in <module>
    from .clipboard import *
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/frontend/events/clipboard.py", line 2, in <module>
    from ..dom import Event
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/frontend/dom.py", line 439, in <module>
    from . import dispatcher
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/frontend/dispatcher.py", line 15, in <module>
    from . import config, server
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/frontend/server.py", line 24, in <module>
    app.mount(config.STATIC_ROUTE, StaticFiles(directory=config.STATIC_DIRECTORY), name=config.STATIC_NAME)
  File "/home/adam/venvs/p3/lib/python3.8/site-packages/starlette/staticfiles.py", line 55, in __init__
    raise RuntimeError(f"Directory '{directory}' does not exist")

Expected behavior (optional)

It should import library

Your configuration (mandatory)

print(sys.version, "\n", sys.platform, "\n")                                                                                                                                               
3.8.3 (default, May 17 2020, 18:15:42) 
[GCC 10.1.0] 
 linux 

I can't provide fitz.__doc__ because importing does not work :)

  • PyMuPDF installed from pip

For example, the output of print(sys.version, "\n", sys.platform, "\n", fitz.__doc__) would be sufficient (for the first two bullets).

Additional context (optional)

It works with python 3.6 venv.

@JorjMcKie
Copy link
Collaborator

The error lines quoted from __init__.py are not contained in PyMuPDF. They demonstrate that you have installed a package named fitz in the same Python where PyMuPDF resides. This cannot coexist with PyMuPDF which has a top-level name of fitz as well.

@JorjMcKie JorjMcKie added not a bug not a bug / user error / unable to reproduce and removed bug labels Jun 3, 2020
@akjanik akjanik closed this as completed Jun 3, 2020
@G4al
Copy link

G4al commented Jul 19, 2020

@akjanik, Hi Adam, how have you managed to solve the issue? I got the same issue, pl. shed a light.

@akjanik
Copy link
Author

akjanik commented Jul 25, 2020

@G4al I have created new venv and run just

pip install pymupdf

without running

pip install fitz

@tyliec
Copy link

tyliec commented May 2, 2021

pip uninstall fitz
into
pip install pymupdf worked for me as well.

@neo9830
Copy link

neo9830 commented Sep 8, 2021

While using fritz, it is adding the inverted image. Did anyone faced this issue?

Please find the below code that I am using:

`import fitz # <-- PyMuPDF
doc = fitz.open("D:\Htc\Python_HTC\PdfAddImage\Sample.pdf") # open the PDF
rect = fitz.Rect(0, 0, 100, 100) # where to put image: use upper left corner

for pageNo, page in enumerate(doc):
if pageNo == 1:
page.insertImage(rect, filename = "D:\Htc\Python_HTC\PdfAddImage\google_logo.png")

doc.saveIncr()

@tanzeelgcuf
Copy link

pip install pymupdf
work for me too
It'll work on python 3.8 and above and
pip install fitz seems like outdated

@JorjMcKie
Copy link
Collaborator

pip install pymupdf work for me too It'll work on python 3.8 and above and pip install fitz seems like outdated

pip install fitz is not outdated but WRONG!
It installs a completely different package, which never has reached more than alpha state and obviously is no longer maintained.

@Sreekiranar
Copy link

pip uninstall fitz into pip install pymupdf worked for me as well.

Thanks a lot!
In my case, I had to uninstall Fitz, and had to force upgrade Pymupdf
pip install --upgrade --force-reinstall pymupdf is what worked for me.

@IsisChameleon
Copy link

Wish I saw those comments earlier! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
Projects
None yet
Development

No branches or pull requests

8 participants