运行docker compose up时“import boto3”的值错误

zbdgwd5y  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(218)

我在运行时看到以下错误 docker-compose up 在我的申请上:

server    | Traceback (most recent call last):
server    |   File "/app/app.py", line 3, in <module>
server    |     import boto3
server    |   File "/usr/local/lib/python3.9/site-packages/boto3/__init__.py", line 16, in <module>
server    |     from boto3.session import Session
server    |   File "/usr/local/lib/python3.9/site-packages/boto3/session.py", line 17, in <module>
server    |     import botocore.session
server    |   File "/usr/local/lib/python3.9/site-packages/botocore/session.py", line 29, in <module>
server    |     import botocore.configloader
server    | ValueError: source code string cannot contain null bytes
server exited with code 1

在我的瓶子里 app.py 我有以下资料:

import flask
import pandas as pd
import boto3

client = boto3.client('s3')
path = 's3://my-bucket/my-file.csv'
df = pd.read_csv(path)
...

当做 flask run 然而,就其本身而言,一切都运转良好。我的 docker-compose.yml 看起来像这样:

version: "3.9"
services:
    server:
        container_name: server
        build: ./server
        ports:
            - "80:5000"
        volumes:
            - ./server:/app
        environment:
            FLASK_ENV: development
        env_file: 
            - ./.env
    web:
        build: ./app
        ports:
            - "3000:3000"
        volumes:
            - ./app:/user/src/app
        depends_on: 
            - server

Dockerfile :

FROM python

WORKDIR /app

ENV FLASK_APP=app.py

ENV FLASK_ENV=development

COPY ./requirements.txt .

RUN pip3 install -r requirements.txt

ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV AWS_REGION='eu-west-2'

COPY . .

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

有办法解决这个问题吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题