Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

pdf_annotate: syntax error #51

Open
jedhelmers opened this issue Apr 13, 2020 · 1 comment
Open

pdf_annotate: syntax error #51

jedhelmers opened this issue Apr 13, 2020 · 1 comment

Comments

@jedhelmers
Copy link

I'm a python noob so I'm probably doing something simple very wrong, but...
I'm trying to run the example from the documentation, but it says there's a syntax error in graphics.py.
Code:

from pdf_annotate import PdfAnnotator, Location, Appearance
a = PdfAnnotator('a.pdf')
a.add_annotation(
    'square',
    Location(x1=50, y1=50, x2=100, y2=100, page=0),
    Appearance(stroke_color=(1, 0, 0), stroke_width=5),
)
a.write('b.pdf')  # or use overwrite=True if you feel lucky

In terminal:

python sample.py

Output:

Traceback (most recent call last):
  File "sample.py", line 1, in <module>
    from pdf_annotate import PdfAnnotator, Location, Appearance
  File "/Users/myusername/Library/Python/2.7/lib/python/site-packages/pdf_annotate/__init__.py", line 2, in <module>
    from pdf_annotate.annotator import PdfAnnotator
  File "/Users/myusername/Library/Python/2.7/lib/python/site-packages/pdf_annotate/annotator.py", line 15, in <module>
    from pdf_annotate.annotations.image import Image
  File "/Users/myusername/Library/Python/2.7/lib/python/site-packages/pdf_annotate/annotations/image.py", line 19, in <module>
    from pdf_annotate.annotations.rect import RectAnnotation
  File "/Users/myusername/Library/Python/2.7/lib/python/site-packages/pdf_annotate/annotations/rect.py", line 12, in <module>
    from pdf_annotate.config.appearance import set_appearance_state
  File "/Users/myusername/Library/Python/2.7/lib/python/site-packages/pdf_annotate/config/appearance.py", line 26, in <module>
    from pdf_annotate.graphics import ContentStream
  File "/Users/myusername/Library/Python/2.7/lib/python/site-packages/pdf_annotate/graphics.py", line 130
    new_parents = (*parents, BaseCommand, namedtuple_klass)
                   ^
SyntaxError: invalid syntax

Any idea what I'm doing wrong?

@jonls
Copy link

jonls commented May 5, 2020

It looks like you are trying to use Python 2.7. This library requires Python 3.5 or later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants