代码之家  ›  专栏  ›  技术社区  ›  user994165

Docker python3:找不到“\u main\u”模块

  •  0
  • user994165  · 技术社区  · 6 年前

    当我跑的时候

    我得到以下错误:

    web_1  | /opt/conda/bin/python3: can't find '__main__' module in 'glm-plotter'
    

    ...
    if __name__ == "__main__":
        app.secret_key = 'B0er23j/4yX R~XHH!jmN]LWX/,?Rh'
        app.run()
    

    Dockerfile文件

    FROM continuumio/miniconda3
    RUN apt-get update && apt-get install -y \
        libpq-dev \
        build-essential
    RUN apt-get install -y python3
    RUN apt-get install -y python3-pip
    
    ADD . /code
    WORKDIR /code
    RUN pip3 install -r requirements.txt
    
    RUN cd glm-plotter
    RUN ls glm-plotter
    CMD ["python3", "glm-plotter"]
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   xrisk    6 年前

    如果glm绘图仪参考 this 然后根据它的文档运行 python glm-plotter.py

    因此,您应该将Dockerfile更改为:

    CMD ["python3", "glm-plotter.py"]