Saturnian
Saturnian

Reputation: 1948

Syntax Error in Python - is this a python version issue?

So, I'm working on deploying a very simple Python Flask application. In my earlier version of Dockerfile I was using ubuntu:20.04 to build my container. But now I've been asked to use my company's base image which I suspect is built on ubuntu 16.04.

And I can't install Python 3.8 on it because the 3.8 package cannot be found(this is the command I've been using RUN apt-get update -y && apt-get install -y python3-pip python3.8) - But it can find Python 3.5 so I'm not installing Python 3.5 (that's the minimum required for Flask)

And then when my container tries to start up in my Kubernetes environment I see this error:

  File "src/app.py", line 55
    logging.info(f"/: launch_code={launch_code}")
                                               ^
SyntaxError: invalid syntax

With the earlier Python 3.8 the application runs perfectly fine without any errors. Is this a Python 3.5 issue?

Upvotes: 0

Views: 409

Answers (1)

Rafael de Bem
Rafael de Bem

Reputation: 827

Since f-strings were introduced in Python 3.6, your code will only run on Python 3.6+.

Upvotes: 3

Related Questions