0

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?

4
  • 11
    f-strings were introduced in Python 3.6, so there's no possibility of this code running on 3.5. Commented Feb 5, 2021 at 19:31
  • Oh I see! Makes a lot of sense! Commented Feb 5, 2021 at 19:35
  • Just to give you a second argument to use a newer Ubuntu version: the support period of Ubuntu 16.04 ends in two months. Commented Feb 5, 2021 at 20:46
  • woot! that's awesome news! hopefully I could use this to convince my devops team to give me a base image of ubuntu 16.10! :D I really like f-strings - I had to change all of my strings to go "string={name}".format(name=name) which looks unsightly! Commented Feb 6, 2021 at 16:54

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.