garettB/shopify-flask-example

Installed requirements but immediate logging error on running server

Opened this issue · 5 comments

File "src/server.py", line 81
logging.error(f"webhook call received {webhook_topic}:\n{json.dumps(webhook_payload, indent=4)}")
^
SyntaxError: invalid syntax

Hi @SnoopLawg, what version of Python are you running?

I'm betting it's complaining about the f-string, which was introduced in Python 3.6 https://realpython.com/python-f-strings/

That solved that issue thank you, but a new one came up now.. /src/server.py", line 6, in <module> from flask import Flask, redirect, request, render_template File "/opt/homebrew/lib/python3.10/site-packages/flask/__init__.py", line 14, in <module> from jinja2 import escape ImportError: cannot import name 'escape' from 'jinja2' (/opt/homebrew/lib/python3.10/site-packages/jinja2/__init__.py)

Unfortunately this is a case of dependency rot -- jinja2's latest version no longer includes the escape module which Flask 1 is relying on here. You could try changing the requirements.txt from Flask 1 to Flask 2 [I do not think there are any breaking changes that would affect this project but ymmv] and re-run pip. If that doesn't work, you could try pinning the jinja2 library < 3.1. Looks like werkzeug might also need to be <= 2.0.2

https://stackoverflow.com/questions/71718167/importerror-cannot-import-name-escape-from-jinja2
pallets/flask#4494

I ran a quick test in a fresh docker container while setting flask=2.2.2 in requirements.txt and server.py started up with no issues. No guarantee that something else may have been changed/broken, but it's a start!

Ok so what i found out for some reason when i updated to the newest version of python with homebrew and set that as my interpreter path in vscode, it did not like that and created errors in general not even just for this repository. Deleting and cleaning this new download through homebrew solved it when I just manually downloaded it from python's website. Thanks for all the help !