Pymupdf: Unable to use fitz with python 3.8

Created on 3 Jun 2020  路  3Comments  路  Source: pymupdf/PyMuPDF

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.

not a bug

Most helpful comment

@G4al I have created new venv and run just

pip install pymupdf

without running

pip install fitz

All 3 comments

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.

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

@G4al I have created new venv and run just

pip install pymupdf

without running

pip install fitz
Was this page helpful?
0 / 5 - 0 ratings

Related issues

axlgit picture axlgit  路  3Comments

harveyspecter09 picture harveyspecter09  路  3Comments

suvinks picture suvinks  路  5Comments

alono88 picture alono88  路  3Comments

smithct2 picture smithct2  路  4Comments