Cimbali / pympress

Pympress is a simple yet powerful PDF reader designed for dual-screen presentations
https://cimbali.github.io/pympress/
GNU General Public License v2.0
1.21k stars 89 forks source link

Homebrew Pympress does not detect manual gstreamer installation #264

Closed timvahlbrock closed 1 year ago

timvahlbrock commented 1 year ago

Describe the bug I had to install gstreamer manually, because the brew installation that came with pympress threw Failed to create 'playbin' element. Check your GStreamer installation. when running gst-play-1.0 (there seem to be issues with the brew formula when used on Apple Silicon) . I have added the Commands folder of the gstreamer installation to the path and gst-play-1.0 works now. However, pympress does not recognise the gstreamer installation, as it prints "GStreamer not available" in the log files.

Latex:

\movie[width=\textwidth]
  {\includegraphics[width=\textwidth]{./video/neumann-cwa-thumbnail.png}}
  {video/neumann-cwa.mp4}\\

To Reproduce Steps to reproduce the behavior:

  1. Install pympress using brew on Apple Silicon.
  2. Uninstall the gstreamer installation that came with it using brew uninstall gst-plugins-bad gst-plugins-base gst-plugins-good gst-plugins-ugly gstreamer --ignore-dependencies
  3. Install gstreamer using the installation package from its website.
  4. Add gstreamer to the path of your shell.
  5. Run a presentation with an embedded video.

Expected behavior The video can be played normally within the presentation.

Environment (please complete the following information):

Debug information (see below for file locations)

My config file has not been modified.

DEBUG:pympress.util:Failed to get git describe output
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/util.py", line 72, in get_pympress_meta
    git_version = subprocess.check_output(command, stderr = subprocess.DEVNULL)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', '--git-dir=/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/.git', 'describe', '--tags', '--long', '--dirty']' returned non-zero exit status 128.
INFO:pympress.app:Pympress: 1.7.2 ; Python: 3.11.1 ; OS: Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 ; Gtk 3.24.36 ; GLib 2.74.0 ; Poppler 23.01.0 cairo ; Cairo 1.16.0 , pycairo 1.23.0
INFO:pympress.extras:Media support: GdkPixbuf gif player, GStreamer not available, VLC not available
ERROR:pympress.scribble:Error creating highlight cache
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/scribble.py", line 412, in reset_scribble_cache
    self.scribble_cache = window.create_similar_image_surface(cairo.Format.ARGB32, ww, wh, scale)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/gi/module.py", line 155, in __getattr__
    setattr(wrapper, value_name, wrapper(value_info.get_value()))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid enum value: 5

Additional context Maybe pympress has some configuration options to configure the location of the gstreamer location already, which I haven't found.

Cimbali commented 1 year ago

Thanks for reporting. The errors we’re seeing are quite benign. Can you try running pympress --log=debug and reporting the log after that? It’s probably a gstreamer install issue indeed, can you import the typelibs from python? Maybe try adjusting GST_PLUGIN_PATH?

timvahlbrock commented 1 year ago

Thanks for the quick response.

Debug Logs

DEBUG:pympress.util:Failed to get git describe output
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/util.py", line 72, in get_pympress_meta
    git_version = subprocess.check_output(command, stderr = subprocess.DEVNULL)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', '--git-dir=/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/.git', 'describe', '--tags', '--long', '--dirty']' returned non-zero exit status 128.
INFO:pympress.app:Pympress: 1.7.2 ; Python: 3.11.1 ; OS: Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 ; Gtk 3.24.36 ; GLib 2.74.0 ; Poppler 23.01.0 cairo ; Cairo 1.16.0 , pycairo 1.23.0
DEBUG:pympress.extras:Media support using GStreamer is disabled.
DEBUG:pympress.extras:Caused by ValueError: Namespace Gst not available
DEBUG:pympress.extras:Media support using VLC is disabled.
DEBUG:pympress.extras:Caused by ModuleNotFoundError: No module named 'vlc'
INFO:pympress.extras:Media support: GdkPixbuf gif player, GStreamer not available, VLC not available
ERROR:pympress.scribble:Error creating highlight cache
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/scribble.py", line 412, in reset_scribble_cache
    self.scribble_cache = window.create_similar_image_surface(cairo.Format.ARGB32, ww, wh, scale)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/gi/module.py", line 155, in __getattr__
    setattr(wrapper, value_name, wrapper(value_info.get_value()))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid enum value: 5
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_UNKNOWN of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 

It’s probably a gstreamer install issue indeed, can you import the typelibs from python?

Like this? This results in the same "Namespace Gst not available" error that is shown in the logs. I took a look at the gi repository, which is resulted within at /opt/homebrew/lib/girepository-1.0/which listed the following.

image

After this I tried running gi.import('Gtk', '3.0'), because that was shown in the gi repository and it succeeded. So it seems like the typelib for gst is missing. So i installed gst-python (which I had uninstalled before, as I thought this would have been reinstalled with gstreamer). And now pympress is showing that i loaded GStreamer 1.20.5. I still cannot play the video though, but I think this issue is fixed.

For completeness:

Maybe try adjusting GST_PLUGIN_PATH?

According to echo $GST_PLUGIN_PATH it is currently unset, as is GI_TYPELIB_PATH.

timvahlbrock commented 1 year ago

Summary: GStreamer wasn't found by python, because gst-python wasn't installed.

timvahlbrock commented 1 year ago

Okay the logs are now as following.

DEBUG:pympress.util:Failed to get git describe output
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/util.py", line 72, in get_pympress_meta
    git_version = subprocess.check_output(command, stderr = subprocess.DEVNULL)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', '--git-dir=/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/.git', 'describe', '--tags', '--long', '--dirty']' returned non-zero exit status 128.
INFO:pympress.app:Pympress: 1.7.2 ; Python: 3.11.1 ; OS: Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 ; Gtk 3.24.36 ; GLib 2.74.0 ; Poppler 23.01.0 cairo ; Cairo 1.16.0 , pycairo 1.23.0
DEBUG:pympress.extras:Media support using VLC is disabled.
DEBUG:pympress.extras:Caused by ModuleNotFoundError: No module named 'vlc'
INFO:pympress.extras:Media support: GdkPixbuf gif player, GStreamer 1.20.5, VLC not available
ERROR:pympress.scribble:Error creating highlight cache
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/scribble.py", line 412, in reset_scribble_cache
    self.scribble_cache = window.create_similar_image_surface(cairo.Format.ARGB32, ww, wh, scale)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/gi/module.py", line 155, in __getattr__
    setattr(wrapper, value_name, wrapper(value_info.get_value()))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid enum value: 5
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_UNKNOWN of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
WARNING:pympress.document:Pympress can not interpret annotation of type: <enum POPPLER_ANNOT_WIDGET of type Poppler.AnnotType> 
DEBUG:pympress.util:Failed to get git describe output
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/util.py", line 72, in get_pympress_meta
    git_version = subprocess.check_output(command, stderr = subprocess.DEVNULL)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', '--git-dir=/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/.git', 'describe', '--tags', '--long', '--dirty']' returned non-zero exit status 128.
INFO:pympress.app:Pympress: 1.7.2 ; Python: 3.11.1 ; OS: Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 ; Gtk 3.24.36 ; GLib 2.74.0 ; Poppler 23.01.0 cairo ; Cairo 1.16.0 , pycairo 1.23.0
DEBUG:pympress.extras:Media support using VLC is disabled.
DEBUG:pympress.extras:Caused by ModuleNotFoundError: No module named 'vlc'
INFO:pympress.extras:Media support: GdkPixbuf gif player, GStreamer 1.20.5, VLC not available
ERROR:pympress.scribble:Error creating highlight cache
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/scribble.py", line 412, in reset_scribble_cache
    self.scribble_cache = window.create_similar_image_surface(cairo.Format.ARGB32, ww, wh, scale)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/gi/module.py", line 155, in __getattr__
    setattr(wrapper, value_name, wrapper(value_info.get_value()))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid enum value: 5
CRITICAL:pympress.__main__:Uncaught exception:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/ui.py", line 1002, in doc_goto_next
    self.goto_page(self.preview_page + 1)
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/ui.py", line 979, in goto_page
    self.do_page_change(autoplay=autoplay)
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/ui.py", line 1140, in do_page_change
    self.medias.replace_media_overlays(self.doc.page(self.current_page), draw_page)
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/extras.py", line 289, in replace_media_overlays
    v_da_c = factory(self.c_overlay, page_type, action_group, media)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pympress/1.7.2_1/libexec/lib/python3.11/site-packages/pympress/media_overlays/gst_backend.py", line 51, in __init__
    self.playbin.set_property('video-sink', self.sink)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'set_property'

This might be related to the unresolved issue https://github.com/Cimbali/pympress/issues/240 Should I open another issue or do we address this here?

timvahlbrock commented 1 year ago

I can reproduce playbin being None outside of pympress.

image
Cimbali commented 1 year ago

Does installing gst-plugin-gtk fix the issue? If so, it's now a duplicate and there isn't much more to do than what's set out in the other issue.

timvahlbrock commented 1 year ago

Seems like I made a mistake. I didn't notice that installing gst-python using brew also reinstalled the brew version of gstreamer, which explains the error pympress threw. Apparently it seems to be the equivalent of the "Failed to create 'playbin' element. Check your GStreamer installation." on the CLI. If I uninstall the gstreamer version brew installed (using --ignore dependencies, so gst-python stays installed) I'm back to gi not being able to require Gst again. Overall, this does not seem to be in the responsibility of pympress, but rather seems to be a problem with either gstreamer, the gstreamer brew formula or having python and gst-python installed over brew, while having a manual gstreamer installation. So I will take a closer look at that and report here if I find something worth documentation or solving the issue. Thanks for your help 🙏

timvahlbrock commented 1 year ago

The issue I opened is https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1702

According to the discussion with the gstreamer devs, the homebrew formula isn't setting the GST_PLUGIN_SYSTEM_PATH environmental variable. Setting it to /opt/homebrew/lib/gstreamer-1.0/ (or where homebrew installed your plugins) makes gst-play-1.0 work. But it seems like pympress still isn't happy with that, it won't even start now. I'm looking into this later.

timvahlbrock commented 1 year ago

Nevermind. Setting GST_PLUGIN_SYSTEM_PATH also makes Pympress work. Maybe this is worth documenting?