简体   繁体   中英

Dockerized streamlit app based on poetry - ModuleNotFoundError: No module named 'Lib'

I build the following docker image. Currently i use the same versions of poetry and python like on my dev system.

FROM python:3.8.8

EXPOSE 8501

ENV PYTHONFAULTHANDLER=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONHASHSEED=random \
    PIP_NO_CACHE_DIR=off \
    PIP_DISABLE_PIP_VERSION_CHECK=on \
    PIP_DEFAULT_TIMEOUT=100 \
    POETRY_VERSION=1.1.7

RUN mkdir /app
COPY . /app
WORKDIR /app
ENV PYTHONPATH=${PYTHONPATH}:${PWD}

RUN pip install --upgrade pip \
    && pip install "poetry==$POETRY_VERSION"

# Install dependencies
RUN poetry config virtualenvs.create false
RUN poetry install --no-interaction --no-dev --no-ansi

CMD ["poetry", "run", "streamlit", "run", "src/projecthours/app.py"]

For some reason the python standard libary is missing. How to fix this error? I wonder why this libary is missing?

from Lib import calendar, datetime, difflib
ModuleNotFoundError: No module named 'Lib'

The solution is to just use the imports directly.

import datetime
import calendar
import difflib

Instead of from Lib import datetime,...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM