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

can't build 1.16.1 - fatal error: fitz.h not exist #358

Closed
alium opened this issue Sep 10, 2019 · 20 comments
Closed

can't build 1.16.1 - fatal error: fitz.h not exist #358

alium opened this issue Sep 10, 2019 · 20 comments
Assignees
Labels

Comments

@alium
Copy link

alium commented Sep 10, 2019

I want build PyMuPDF as usually i build python-packages, ergo:

python setup.py build, python setup.py install --root="$pkgdir" --optimize=1

but i can build that, because fitz.h missing

log:
running build
running build_py
running build_ext
building 'fitz._fitz' extension
swigging fitz/fitz.i to fitz/fitz_wrap.c
swig -python -o fitz/fitz_wrap.c fitz/fitz.i
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/fitz
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fstack-protector-strong -fno-plt -march=haswell -mtune=haswell -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -I/usr/include/python3.7m -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.7/fitz/fitz_wrap.o
fitz/fitz_wrap.c:2732:10: fatal error: fitz.h: directory or file does not exist
2732 | #include <fitz.h>
| ^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1


1.16.1 and 1.14.18 tested and both are affected...

maybe stupid question, but i found no solution....

@JorjMcKie
Copy link
Collaborator

Have you read the installation documentation of the manual and the hints on the homepage of the repo?

  • Downloaded & installed MuPDF from their download (!) site?
  • Downloaded PyMuPDF source from PyPI?
  • Copied the _config.h from the fitz folder of the repo to the downloaded MuPDF folder replacing config.h (without underscore) there?
  • Generated MuPDF after all the previous steps?
  • Adjusted any folder names in setup.py?

Your error means that the MuPDF source is not accessible - a clear sign that you missed one or more of the previous steps: fitz.h is contained in mupdf/include/mupdf, which therefore must be missing in your setup.py.

@alium
Copy link
Author

alium commented Sep 10, 2019

pretty stupid installation :-D

@emacs18
Copy link

emacs18 commented Dec 22, 2019

I ran into the same error on a freshly installed CentOS 8 while running

pip3 install --user pymudpf

Prior to this following completed successfully:

sudo yum install python3-qt5-devel.x86_64
pip3 install --user dbus-python python-xlib pyqt5 pyqtwebengine grip qrcode feedparser

Must I build pymudpdf from source and not using pip3?
I don't even know what pymupdf is. I'm just trying to follow instructions at
https://github.com/manateelazycat/emacs-application-framework
ie., pymupdf is just one of many preprequisites.

@JorjMcKie
Copy link
Collaborator

Must I build pymudpdf from source and not using pip3?
I don't even know what pymupdf is. I'm just trying to follow instructions at
https://github.com/manateelazycat/emacs-application-framework
ie., pymupdf is just one of many preprequisites.

  1. PyMuPDF is a package to access PDF and many other document types (XPS, EPUB, ...) from Python.
  2. I am not familiar with CentOS, but obviously it is not one of the OS upported by the wheels I am offering on PyPI. I am a little surprised, that this Linux type wouldn't be among the ones supported by the platform tag manylinux2010. If you know what you are doing, you can even unzip the right wheel version an manually copy those 5 files to your dist or site packages ... There are also tools to convert wheels back to an egg format, which is certainly cleaner (https://github.com/dairiki/humpty). This in the hope, that the egg install will be less picky that pip.
  3. In that case one must install from sources. As such not a big deal (and you can use pip3 for it), but before this, the base library MuPDF must be installed. This is explained on the homepage and more dilligently in the PyMuPDF documentation.

@emacs18
Copy link

emacs18 commented Dec 23, 2019

Thank you for your reply.
I will try to build this from source.
The only reason why I bother with CentOS is that it is used in my day job.
Compared with ubuntu, centos seems like it is from dinosaur age as far as basic user experience goes.
I can't see why anyone would choose to use this for personal use.

@chenghaitao
Copy link

$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5a/4a/39400ff9b36e719bdf8f31c99fe1fa7842a42fa77432e584f707a5080063/pip-20.2.2-py2.py3-none-any.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 408kB/s
Installing collected packages: pip
Successfully installed pip-20.2.2

@susuusus
Copy link

Hi @JorjMcKie , correct me if I am wrong .Once I installed pymupdf, mupdf should get automatically downloaded in window and linux, but why I still encounter the issue that fitz.h not found

@JorjMcKie
Copy link
Collaborator

JorjMcKie commented Nov 18, 2020

Once I installed pymupdf, mupdf should get automatically downloaded in window and linux

No, this won't (and should not!) happen automatically. You must download and install MuPDF as a separate step prior to generating PyMuPDF from source.

@susuusus
Copy link

susuusus commented Nov 18, 2020 via email

@JorjMcKie
Copy link
Collaborator

JorjMcKie commented Nov 18, 2020 via email

@denyu95
Copy link

denyu95 commented Dec 1, 2020

Maybe you need to upgrade pip first

  1. pip3 install --upgrade pip
  2. pip3 install PyMuPDF
    Good luck

@hammady
Copy link

hammady commented May 2, 2021

For anyone trying to install mupdf on Apple's M1 or any arm based architecture, there is no binary available for arm and pip will try to build from source. Until the maintainers here provide system requirements to install before pip, this will always fail.

@sailist
Copy link

sailist commented Oct 30, 2021

my m1 solution:

brew install mupdf
pip3 install PyMuPDF

@NixBiks
Copy link

NixBiks commented Jan 25, 2022

my m1 solution:

brew install mupdf
pip3 install PyMuPDF

@sailist Have you been able to install pymupdf in a docker container (e.g. based on python:3.8-bullseye) on your M1 machine? I keep getting the following error

  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -Imupdf/thirdparty/freetype/include -I/usr/include/freetype2 -I/opt/pysetup/.venv/include -I/usr/local/include/python3.8 -c fitz/fitz_wrap.c -o build/temp.linux-aarch64-3.8/fitz/fitz_wrap.o
  fitz/fitz_wrap.c:2755:10: fatal error: fitz.h: No such file or directory
   2755 | #include <fitz.h>
        |          ^~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1

@lucasfonsecads
Copy link

@mr-bjerre In the case of Docker, you need to check if your image is using an image that is not based on the M1 architecture, so you won't have any problems installing packages that don't work on M1.

@NixBiks
Copy link

NixBiks commented Jan 28, 2022

I solved it. See my solution here

@charanjit-singh
Copy link

charanjit-singh commented Apr 4, 2022

on MBPro M1
After running
brew install mupdf
I am getting
fatal error: 'ft2build.h' file not found

@V-Holodov
Copy link

V-Holodov commented Apr 4, 2022

@charanjit-singh On an ARM M1 Mac, with native homebrew & pip in place, these steps should work (the second step being replaced by pip install pymupdf as soon as the referenced PR reach PyPI):

brew install mupdf swig
pip install https://github.com/pymupdf/PyMuPDF/archive/master.tar.gz

#875

@mojo-anand
Copy link

mojo-anand commented May 23, 2022

on Mac M1, I was getting:
fatal error: 'ft2build.h' file not found
had to additionally do:
brew install freetype

@ZaXk
Copy link

ZaXk commented Jun 27, 2022

My solution(for alpine 3.16):
apk add
mupdf-dev
gcc
make
libc-dev
musl-dev
jbig2dec
openjpeg-dev
jpeg-dev
harfbuzz-dev
swig

ln -s /usr/lib/libjbig2dec.so.0 /usr/lib/libjbig2dec.so

python -m pip install --upgrade pip
python -m pip install --upgrade pymupdf

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

No branches or pull requests