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

PyMuPDF Installation Error in cPanel #2671

Closed
Yasmina118 opened this issue Sep 15, 2023 · 9 comments
Closed

PyMuPDF Installation Error in cPanel #2671

Yasmina118 opened this issue Sep 15, 2023 · 9 comments

Comments

@Yasmina118
Copy link

0

I'm currently working on a Python project that involves PyMuPDF for PDF processing. I've successfully written the Python script and have it running as expected on my local development environment. Now, I'm in the process of deploying this script on cPanel. When I attempt to install Pymupdf within the cPanel terminal using the command "pip install pymupdf," I encountered the following error:


Collecting pymupdf==1.22.5
Using cached PyMuPDF-1.22.5.tar.gz (61.6 MB)
Installing build dependencies … done
Getting requirements to build wheel … done
Installing backend dependencies … done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pymupdf
Building wheel for pymupdf (pyproject.toml) … error
error: subprocess-exited-with-error

× Building wheel for pymupdf (pyproject.toml) did not run successfully.
│ exit code: 1
╰─\> \[73 lines of output\]
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: sys.argv: ['/home/pathto/virtualenv/python/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py', 'bdist_wheel', '--dist-dir', '/tmp/pip-wheel-mg640akx/.tmp-r18qslxs']
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: os.getcwd(): /tmp/pip-install-47afuc7u/pymupdf_7e40f6743aad46ce8053534f66c089dc
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: __file__: /tmp/pip-install-47afuc7u/pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: $PYTHON_ARCH: None
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: os.environ (34):
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     MANPATH: :/opt/puppetlabs/puppet/share/man
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     HOSTNAME: n3plcpnl0084.prod.ams3.secureserver.net
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     TERM: xterm-256color
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     HISTSIZE: 1000
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     USER: pathto
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     LS_COLORS: rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     OPENSSL_NO_DEFAULT_ZLIB: 1
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     VIRTUAL_ENV: /home/pathto/virtualenv/python/3.11
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     MAIL: /var/spool/mail/pathto
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PATH: /tmp/pip-build-env-edsvupyn/overlay/bin:/tmp/pip-build-env-edsvupyn/normal/bin:/home/pathto/virtualenv/python/3.11/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/opt/alt/ruby27/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin:/opt/cpanel/composer/bin:/opt/puppetlabs/bin:/opt/dell/srvadmin/bin:/usr/local/bin:/usr/X11R6/bin:/home/pathto/.local/bin:/home/pathto/bin
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PWD: /home/pathto/public_html/pdf.weserv.be/public
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     JAVA_HOME: /usr/local/jdk
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     EDITOR: vim
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     LANG: C
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PS1: ((python:3.11)) \[\]\u\[\]@\[\]\h\[\] [\w]\[\]\[\]\$\[\]
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     HISTCONTROL: ignoredups
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     A3_CACHE_SIZE: 4G
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     SHLVL: 1
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     HOME: /home/pathto
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     LS_OPTIONS: --color=tty -F -a -b -T 0
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     LESS: -I -P[\"?f%f:Standard input.\" - ?ltLine %lt?L of %L..?pt (%pt\%).?e (END).]
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     LOGNAME: pathto
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     VISUAL: vim
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     CVS_RSH: ssh
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     CLASSPATH: .:/usr/local/jdk/lib/classes.zip
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     LESSOPEN: ||/usr/bin/lesspipe.sh %s
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     G_BROKEN_FILENAMES: 1
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     HISTTIMEFORMAT: %d/%m/%y %T
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     _: /home/pathto/virtualenv/python/3.11/bin/pip
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     OLDPWD: /home/pathto
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PIP_BUILD_TRACKER: /tmp/pip-build-tracker-p70lxa8_
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PYTHONNOUSERSITE: 1
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PYTHONPATH: /tmp/pip-build-env-edsvupyn/site
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py:     PEP517_BUILD_BACKEND: setuptools.build_meta
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: platform.system()='Linux'
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: sys.platform='linux'
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: PYMUPDF_SETUP_MUPDF_BUILD=None
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: mupdf_tgz already exists: /tmp/pip-install-47afuc7u/pymupdf_7e40f6743aad46ce8053534f66c089dc/mupdf.tgz
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: Extracting /tmp/pip-install-47afuc7u/pymupdf_7e40f6743aad46ce8053534f66c089dc/mupdf.tgz
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: mupdf_local='mupdf-1.22.2-source'
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: Building mupdf.
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: Copying fitz/_config.h to mupdf-1.22.2-source/include/mupdf/fitz/config.h
      pymupdf_7e40f6743aad46ce8053534f66c089dc/setup.py: Building MuPDF by running: cd mupdf-1.22.2-source &&  CFLAGS="-fPIC" make HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no HAVE_LEPTONICA=yes HAVE_TESSERACT=yes verbose=yes build=release build_prefix=pymupdf-x86_64- && echo mupdf-1.22.2-source/build/pymupdf-x86_64-release: && ls -l build/pymupdf-x86_64-release
      mkdir -p build/pymupdf-x86_64-release/source/fitz/ ; cc -fPIC -ffunction-sections -fdata-sections -pipe -O2 -DNDEBUG -fomit-frame-pointer  -Iinclude -MMD -MP -o build/pymupdf-x86_64-release/source/fitz/archive.o -c source/fitz/archive.c -Wall -Wsign-compare -Wdeclaration-after-statement  -Ithirdparty/freetype/include -Iscripts/freetype -Ithirdparty/gumbo-parser/src -Ithirdparty/harfbuzz/src -Ithirdparty/libjpeg -Iscripts/libjpeg -Ithirdparty/lcms2/include -DHAVE_LCMS2MT -Ithirdparty/mujs -Ithirdparty/zlib -Ithirdparty/jbig2dec -Ithirdparty/openjpeg/src/lib/openjp2 -DOPJ_STATIC -DOPJ_HAVE_INTTYPES_H -DOPJ_HAVE_STDINT_H -DHAVE_LEPTONICA -Ithirdparty/leptonica/src -DHAVE_TESSERACT -Ithirdparty/tesseract/include -Iscripts/tesseract -Ithirdparty/extract/include -Ithirdparty/extract/src
      In file included from include/mupdf/fitz.h:76,
                       from source/fitz/archive.c:23:
      include/mupdf/fitz/link.h:64: error: redefinition of typedef 'fz_link'
      include/mupdf/fitz/link.h:31: note: previous declaration of 'fz_link' was here
      make: *** [build/pymupdf-x86_64-release/source/fitz/archive.o] Error 1
      Traceback (most recent call last):
        File "/home/pathto/virtualenv/python/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/pathto/virtualenv/python/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pathto/virtualenv/python/3.11/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-edsvupyn/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 434, in build_wheel
          return self._build_with_temp_dir(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-edsvupyn/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 419, in _build_with_temp_dir
          self.run_setup()
        File "/tmp/pip-build-env-edsvupyn/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 702, in <module>
        File "/opt/alt/python311/lib64/python3.11/subprocess.py", line 571, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command 'cd mupdf-1.22.2-source &&  CFLAGS="-fPIC" make HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no HAVE_LEPTONICA=yes HAVE_TESSERACT=yes verbose=yes build=release build_prefix=pymupdf-x86_64- && echo mupdf-1.22.2-source/build/pymupdf-x86_64-release: && ls -l build/pymupdf-x86_64-release' returned non-zero exit status 2.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pymupdf
Failed to build pymupdf
ERROR: Could not build wheels for pymupdf, which is required to install pyproject.toml-based projects

I've already upgraded pip, setuptools, and wheel using the command "pip install --upgrade pip setuptools wheel" but still get the same error. also tried pip install --only-binary=numpy numpy and pip install --only-binary=pymupdf pymupdf and pip install --only-binary=fitz fitz .
When I searched, I found that maybe I should install python-devel. However, I don't have access to use the sudo command in cPanel terminal. Are there any other solutions that I can try?

@julian-smith-artifex-com
Copy link
Collaborator

Thanks for the bug report.

It looks like your system's C compiler thinks this code is redefining typedef 'fz_link' in MuPDF's include/mupdf/fitz/link.h:

typedef struct fz_link fz_link;
...
typedef struct fz_link
{
	int refs;
	struct fz_link *next;
	fz_rect rect;
	char *uri;
	fz_link_set_rect_fn *set_rect_fn;
	fz_link_set_uri_fn *set_uri_fn;
	fz_link_drop_link_fn *drop;
} fz_link;

I've never seen this on any of our test systems, so i wonder whether you could post the exact details of your C compiler - e.g. with cc -v and cc --version.

[It's possible that we can avoid the error my modifying the above MuPDF code, changing typedef struct fz_link {...} fz_link; to struct fz_link {...};, but i suspect your system's compiler will fail elsewhere anyway.]

@Yasmina118
Copy link
Author

Thank you for answering my question! Here's my C compiler version:
gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.

@julian-smith-artifex-com
Copy link
Collaborator

Ok, that's really old. I don't think you're going to be able to build MuPDF or PyMuPDF unless you get a much newer compiler.

Incidently, how come pip is trying to build from source instead of using a pre-built PyMuPDF wheel? There are wheels for Linux/x86_64.

@JorjMcKie
Copy link
Collaborator

@yamina118 - any news on your problem?

@Yasmina118
Copy link
Author

@JorjMcKie I will try to update my C compilers. To do so, I need to buy a VPS. I anticipate completing this task within the next week. I'll keep you posted on the progress. Thank you for your time and assistance! Should I close the issue?

@JorjMcKie
Copy link
Collaborator

@JorjMcKie I will try to update my C compilers. To do so, I need to buy a VPS. I anticipate completing this task within the next week. I'll keep you posted on the progress. Thank you for your time and assistance! Should I close the issue?

We actually had hoped that you can find a wheel on PyPI that suits your needs. We don't understand yet, why your Python / pip triggered an installation from sources.
Are you sure you have updated pip to the newest version: python -m pip install --update pip?
This is important, because usually only newer pip versions are able to correctly interpret some platforms, so it will pick a suitable wheel for you. If it finds a wheel, you need no compilation at all.

If you haven't: can you repeat the installation by first upgrading pip, then installing pymupdf?

@julian-smith-artifex-com
Copy link
Collaborator

I wonder if @yamina118's system (e.g. glibc) is too old for PyMuPDF's manylinux2014 wheels.

https://github.com/pypa/manylinux has information on what systems are compatible with manylinux2014 wheels.

@yamina118 - what is the output of uname -a on your system?

@Yasmina118
Copy link
Author

@julian-smith-artifex-com the output of uname -a is uname -a
Linux n3plcpnl0084.prod.ams3.secureserver.net 2.6.32-954.3.5.lve1.4.92.el6.x86_64 #1 SMP Tue Jul 4 15:05:25 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
@JorjMcKie As you suggested, I tried to install PyMuPDF using the following command: pip install PyMuPDF-1.23.3-cp311-none-manylinux2014_x86_64.whl. However, I encountered the following error: ERROR: PyMuPDF-1.23.3-cp311-none-manylinux2014_x86_64.whl is not a supported wheel on this platform.
As for python -m pip install --upgrade pip I get the following output: Requirement already satisfied: pip in /home/../virtualenv/python/3.11/lib/python3.11/site-packages (23.2.1)

@julian-smith-artifex-com
Copy link
Collaborator

Ok, i think your system is too old to work with PyMuPDF wheels, which are built with the manylinux2014 tag so from https://github.com/pypa/manylinux the oldest Linux systems they work with are:

CentOS 7 rh-python38, CentOS 8 python38, Fedora 32+, Mageia 8+, openSUSE 15.3+, Photon OS 4.0+ (3.0+ with updates), Ubuntu 20.04+

Also, i'm not sure you'll be able to build PyMuPDF from source even if you somehow manage to upgrade your compilers - e.g. the build automatically installs the swig and libclang packages, which in turn may not install or build themselves.

So i think you need to upgrade your system.

I'll close this bug now, but feel free to post again if you have more questions.

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