metaist / pdfmerge

Command-line utility for merging, splicing, and rotating PDF documents.
http://metaist.github.io/pdfmerge/
Other
121 stars 24 forks source link

Syntax error when running from CLI #16

Closed ismailuddin closed 8 years ago

ismailuddin commented 8 years ago

When I run pdfmerge -o out.pdf "file.pdf" "other.pdf" or pdfmerge -o out.pdf "file.pdf, other.pdf" I get the following error:

Traceback (most recent call last):
  File "C:\Python27\Scripts\pdfmerge-script.py", line 9, in <module>
    load_entry_point('pdfmerge==0.0.7', 'console_scripts', 'pdfmerge')()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2229, in load
    return self.resolve()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "C:\Python27\Scripts\pdfmerge.py", line 5, in <module>
    from pdftools import pdf_merge
  File "c:\python27\lib\site-packages\pdftools\__init__.py", line 5, in <module>
    from pdftools.pdftools import pdf_merge, pdf_rotate, pdf_split, pdf_zip, \
  File "c:\python27\lib\site-packages\pdftools\pdftools.py", line 15
    def pdf_merge(inputs: [str], output: str, delete: bool=False):
                        ^
SyntaxError: invalid syntax

But, if I run it from a Python prompt as follows:

pdfmerge.merge(["file.pdf", "other.pdf"], 'out.pdf')

it works fine..Any suggestions?

metaist commented 8 years ago

Hi @ismailuddin!

At first, I was confused because the line that has the syntax error looks like Python 3 code, but I see from your paths that you're using Python 2.7.

It looks like you have pdftools installed which also has a file called pdfmerge.py. This causes a conflict when my pdfmerge CLI wrapper tries to run because it unintentionally loads the file from pdftools instead of my library.

Because this has a lot to do with how your python paths are configured, the I see two ways to fix this quickly: either uninstall pdftools or use virtualenv to install pdfmerge into its own environment without name conflicts.