Issues installing ueberzug on macos

Question:

I’ve been using the lf file manager lately and wanted to try setting up ueberzug as my previewer. However, getting ueberzug to install and run properly on my mac has been a real issue. Is it perhaps that I’m missing some dependencies, like X11 or some other library? I’d really appreciate it if someone could lend me a hand and help me figure this out

Here is the command I ran:
pip3 install ueberzug

Here is the return code:

Collecting ueberzug
  Using cached ueberzug-18.1.9.tar.gz (36 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: python-xlib in /opt/homebrew/lib/python3.10/site-packages (from ueberzug) (0.31)
Requirement already satisfied: pillow in /opt/homebrew/lib/python3.10/site-packages (from ueberzug) (9.2.0)
Requirement already satisfied: docopt in /opt/homebrew/lib/python3.10/site-packages (from ueberzug) (0.6.2)
Requirement already satisfied: attrs>=18.2.0 in /opt/homebrew/lib/python3.10/site-packages (from ueberzug) (22.1.0)
Requirement already satisfied: six>=1.10.0 in /opt/homebrew/lib/python3.10/site-packages (from python-xlib->ueberzug) (1.16.0)
Building wheels for collected packages: ueberzug
  Building wheel for ueberzug (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [51 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-12-arm64-cpython-310
      creating build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/scaling.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/tmux_util.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/files.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/xutil.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/loading.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/thread.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/version.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/library.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/terminal.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/ui.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/batch.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/conversion.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/__init__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/pattern.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/query_windows.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/action.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/parser.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/geometry.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/layer.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/process.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/__main__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      creating build/lib.macosx-12-arm64-cpython-310/ueberzug/lib
      copying ueberzug/lib/__init__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug/lib
      creating build/lib.macosx-12-arm64-cpython-310/ueberzug/lib/v0
      copying ueberzug/lib/v0/__init__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug/lib/v0
      running egg_info
      writing ueberzug.egg-info/PKG-INFO
      writing dependency_links to ueberzug.egg-info/dependency_links.txt
      writing entry points to ueberzug.egg-info/entry_points.txt
      writing requirements to ueberzug.egg-info/requires.txt
      writing top-level names to ueberzug.egg-info/top_level.txt
      reading manifest file 'ueberzug.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'ueberzug.egg-info/SOURCES.txt'
      copying ueberzug/lib/lib.sh -> build/lib.macosx-12-arm64-cpython-310/ueberzug/lib
      running build_ext
      building 'Xshm' extension
      creating build/temp.macosx-12-arm64-cpython-310
      creating build/temp.macosx-12-arm64-cpython-310/Xshm
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Xshm/Xshm.c -o build/temp.macosx-12-arm64-cpython-310/Xshm/Xshm.o
      Xshm/Xshm.c:5:10: fatal error: 'X11/Xlib.h' file not found
      #include <X11/Xlib.h>
               ^~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for ueberzug
  Running setup.py clean for ueberzug
Failed to build ueberzug
Installing collected packages: ueberzug
  Running setup.py install for ueberzug ... error
  error: subprocess-exited-with-error

  × Running setup.py install for ueberzug did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      running install
      /opt/homebrew/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.macosx-12-arm64-cpython-310
      creating build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/scaling.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/tmux_util.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/files.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/xutil.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/loading.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/thread.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/version.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/library.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/terminal.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/ui.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/batch.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/conversion.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/__init__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/pattern.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/query_windows.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/action.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/parser.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/geometry.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/layer.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/process.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      copying ueberzug/__main__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug
      creating build/lib.macosx-12-arm64-cpython-310/ueberzug/lib
      copying ueberzug/lib/__init__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug/lib
      creating build/lib.macosx-12-arm64-cpython-310/ueberzug/lib/v0
      copying ueberzug/lib/v0/__init__.py -> build/lib.macosx-12-arm64-cpython-310/ueberzug/lib/v0
      running egg_info
      writing ueberzug.egg-info/PKG-INFO
      writing dependency_links to ueberzug.egg-info/dependency_links.txt
      writing entry points to ueberzug.egg-info/entry_points.txt
      writing requirements to ueberzug.egg-info/requires.txt
      writing top-level names to ueberzug.egg-info/top_level.txt
      reading manifest file 'ueberzug.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'ueberzug.egg-info/SOURCES.txt'
      copying ueberzug/lib/lib.sh -> build/lib.macosx-12-arm64-cpython-310/ueberzug/lib
      running build_ext
      building 'Xshm' extension
      creating build/temp.macosx-12-arm64-cpython-310
      creating build/temp.macosx-12-arm64-cpython-310/Xshm
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Xshm/Xshm.c -o build/temp.macosx-12-arm64-cpython-310/Xshm/Xshm.o
      Xshm/Xshm.c:5:10: fatal error: 'X11/Xlib.h' file not found
      #include <X11/Xlib.h>
               ^~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> ueberzug

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Asked By: Aloous

||

Answers:

For those struggling with the same issue, all you have to do is add a few lines into your pydistutils.cfg file. If you don’t have this file simply create the file in your home directory with the command:
touch ~/.pydistutils.cfg. Then add the following lines into your ~/.pydistutils.cfg:

[build_ext]
include_dirs=/opt/X11/include
library_dirs=/opt/X11/lib

All credit goes to this website for solving the issue https://dotfiles.rickbooth.me/docs/terminal/ueberzug

Answered By: Aloous
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.