Interactive debugging from docker-compose: SyntaxError: Non-UTF-8 code starting with '\xff'

docker compose up, works as is, but I have been trying to setup interactive debugging with pycharm and ran into many difficulties

FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 1
In folder /home/xxx/workspace/xxx-xxxx/flaskProject
/usr/bin/docker-compose -f /home/xxx/workspace/xxx-xxxx/docker-compose.yml -f /home/xxx/.cache/JetBrains/PyCharm2022.3/tmp/docker_compose/docker-compose.override.903.yml up --exit-code-from filesvc --abort-on-container-exit filesvc
Recreating xxx-xxxx_filesvc_1 ... 
Attaching to xxx-xxxx_filesvc_1
filesvc_1  | SyntaxError: Non-UTF-8 code starting with '\xff' in file /usr/local/bin/python3 on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
xxx-xxxx_filesvc_1 exited with code 1
Aborting on container exit...

Process finished with exit code 1

Here's the interpreter setup

The dockerfile

# syntax=docker/dockerfile:1.4
FROM python:3.10-alpine AS builder

WORKDIR /code

COPY requirements.txt /code
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install -r requirements.txt


COPY . /code

ENTRYPOINT ["python3"]
CMD ["app.py"]

FROM builder as dev-tools

RUN apk update
RUN apk add git bash

while the docker-compose.yml

version: "3.3"
volumes:
data:
services:
filesvc:
build: ./flaskProject
image: flask
volumes:
- data:/mnt/data/flask:rw
ports:
- 8080:8080
3
1 comment

did u find a solution?

0

Please sign in to leave a comment.