Bug 1648514

Summary: pdfshuffler Requires the wrong library
Product: [Fedora] Fedora Reporter: Peter Simonyi <rhbz>
Component: pdfshufflerAssignee: Fabian Affolter <mail>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 31CC: a9016009, bebo.sudo, bugzilla, d.bz-redhat, dreua, erik, lagarcia, mail, pgrahamdev, red
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-14 14:10:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1592820    
Bug Blocks:    

Description Peter Simonyi 2018-11-10 06:53:57 UTC
Description of problem:
pdfshuffler-0.6.0-15.fc30 Requires: python2-PyPDF2, but the application actually imports pyPdf which is provided by pyPdf-1.13-16.fc29.

Version-Release number of selected component (if applicable):
0.6.0-15.fc30

How reproducible:
Always

Steps to Reproduce:
1. On a fresh Rawhide box (i.e. without pyPdf installed), dnf install pdfshuffler
2. Run pdfshuffler

Actual results:
Printed in the console:
Error: Could not import pdfshuffler
Cause: No module named pyPdf

Expected results:
pdfshuffler opens successfully.

Additional info:
I see that python2-PyPDF2 is required by pdfshuffler, and is installed by dnf, but that doesn't satisfy the 'import pyPdf'.  pdfshuffler will run successfully after installing pyPdf.

Comment 1 Erik Johnson 2019-04-09 19:21:42 UTC
Simple patch to use "current" PyPDF2

--- /tmp/pdfshuffler.py 2019-04-09 21:17:43.853853247 +0200
+++ /usr/lib/python2.7/site-packages/pdfshuffler/pdfshuffler.py 2019-04-09 21:08:36.218092511 +0200
@@ -71,7 +71,7 @@
 import cairo
 
 import poppler      #for the rendering of pdf pages
-from pyPdf import PdfFileWriter, PdfFileReader
+from PyPDF2 import PdfFileWriter, PdfFileReader
 
 from pdfshuffler_iconview import CellRendererImage
 gobject.type_register(CellRendererImage)

Comment 2 Alberto Chiusole 2019-05-21 21:36:54 UTC
I just tried the suggestion above by Erik Johnson, but it didn't help.

# pdfshuffler 
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
Traceback (most recent call last):
  File "/usr/bin/pdfshuffler", line 30, in <module>
    from pdfshuffler.pdfshuffler import main
  File "/usr/lib/python2.7/site-packages/pdfshuffler/pdfshuffler.py", line 81, in <module>
    class PdfShuffler:
  File "/usr/lib/python2.7/site-packages/pdfshuffler/pdfshuffler.py", line 83, in PdfShuffler
    'window width': min(700, gtk.gdk.screen_get_default().get_width() / 2),
AttributeError: 'NoneType' object has no attribute 'get_width'


I also tried with a symbolic link, but it broke in the same way:

# cd /usr/lib/python2.7/site-packages/
# ln -s PyPDF2 pyPdf
# pdfshuffler 
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
Traceback (most recent call last):
  File "/usr/bin/pdfshuffler", line 30, in <module>
    from pdfshuffler.pdfshuffler import main
  File "/usr/lib/python2.7/site-packages/pdfshuffler/pdfshuffler.py", line 81, in <module>
    class PdfShuffler:
  File "/usr/lib/python2.7/site-packages/pdfshuffler/pdfshuffler.py", line 83, in PdfShuffler
    'window width': min(700, gtk.gdk.screen_get_default().get_width() / 2),
AttributeError: 'NoneType' object has no attribute 'get_width'


It seems to me that the API between pyPdf and PyPDF2 is different.

Comment 3 David Auer 2019-05-23 10:10:40 UTC
This is unrelated to pyPdf / PyPDF2 imo. The log sys that it has trouble opening a display, so rather GTK related. 
Maybe check if the DISPLAY environment variable is set correctly (echo $DISPLAY). Maybe you are trying this over SSH? Have you tried running pdfshuffler via the launcher?

BTW: I would recommend everyone to have a look at pdfarranger, it's better supported, Python3, GTK3 and PyPDF2 by default.

Github: https://github.com/jeromerobert/pdfarranger
Copr: https://copr.fedorainfracloud.org/coprs/dreua/python-pdfarranger/
Package review request: https://bugzilla.redhat.com/show_bug.cgi?id=1711611

Comment 4 psg_nm 2019-05-27 04:40:55 UTC
I am seeing the same problem on a Fedora 29 KDE Plasma Spin that has been upgraded to Fedora 30 before installing "pdfshuffler".  On a machine where I installed "pdfshuffler" under Fedora 29 (KDE Plasma Spin) and then upgraded to Fedora 30, "pdfshuffler" works just fine.  Looking at the machine where "pdfshuffler" was installed under Fedora 29 (before the upgrade) the old dependency was installed under Fedora 29 and is still there ("pyPdf-1.13-16.fc29.noarch").

On the machine where "pdfshuffler" was installed after the upgrade to Fedora 30, running "pdfshuffler" from the command line, I get:

Error: Could not import pdfshuffler
Cause: No module named pyPdf

Looking for pyPdf using "dnf list *pyPdf*", I get:

$ dnf list *pypdf*
Last metadata expiration check: 0:01:15 ago on Sun 26 May 2019 10:11:38 PM MDT.
Installed Packages
python2-PyPDF2.noarch                            1.26.0-7.fc30                          @fedora
Available Packages
python-PyPDF2-doc.noarch                         1.26.0-7.fc30                          fedora 
python3-PyPDF2.noarch                            1.26.0-7.fc30                          fedora 

Looking at the "pdfshuffler" package using "rpm -q -i pdfshuffler --requires":

$ rpm -q -i pdfshuffler --requires
Name        : pdfshuffler
Version     : 0.6.0
Release     : 16.fc30
Architecture: noarch
Install Date: Sun 26 May 2019 09:56:15 PM MDT
Group       : Unspecified
Size        : 233828
License     : GPLv2+
Signature   : RSA/SHA256, Sat 02 Feb 2019 01:24:17 AM MST, Key ID ef3c111fcfc659b9
Source RPM  : pdfshuffler-0.6.0-16.fc30.src.rpm
Build Date  : Fri 01 Feb 2019 11:44:54 PM MST
Build Host  : buildvm-ppc64le-28.ppc.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://sourceforge.net/projects/pdfshuffler/
Bug URL     : https://bugz.fedoraproject.org/pdfshuffler
Summary     : PDF file merging, rearranging, and splitting
Description :
PDF-Shuffler is a small python-gtk application, which helps the user
to merge or split pdf documents and rotate, crop and rearrange their
pages using an interactive and intuitive graphical interface.
/usr/bin/python2
pygtk2
pypoppler
python(abi) = 2.7
python2-PyPDF2
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1

It looks like the python2-PyPDF2 is installed, but it still doesn't run.

Applying Erik Johnson's fix above worked for me, so /usr/lib/python2.7/site-packages/pdfshuffler/pdfshuffler.py looks like it needs to be updated and the RPM's dependencies are actually OK.

Comment 5 psg_nm 2019-05-27 04:47:06 UTC
This seems to be a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1592820 , which might resolve the issue.

Comment 6 Fabian Affolter 2019-05-30 10:36:02 UTC
*** Bug 1708993 has been marked as a duplicate of this bug. ***

Comment 7 Ben Cotton 2019-08-13 16:48:15 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 8 Fabian Affolter 2019-10-14 14:10:04 UTC
pdfshuffler will be replaced by pdfarranger.

Comment 9 Andre Klapper 2019-10-26 01:02:04 UTC
*** Bug 1765781 has been marked as a duplicate of this bug. ***

Comment 10 Erik del Toro Streb 2020-01-14 12:26:01 UTC
As a temporary and easy workaround you could just install the missing package.

    pip2 install pyPdf

Source: https://superuser.com/questions/1515843/pdf-shuffler-wont-run

I did this, because pdfarranger takes very long to start.