简体   繁体   English

Jupyter/Python/Docker。 需要得到一个输出csv

[英]Jupyter/Python/Docker. Need to get an output csv

have the following:有以下内容:

Hello.ipynb你好.ipynb

    import pandas as pd
    df = pd.DataFrame({'name' : ['Max', 'Oleg', 'John'],
                      'results' : [100, 2, 3]})
    df.to_csv(r'C:\Scripts\df.csv', index = False)

Dockerfile: Dockerfile:

    FROM python:latest
    RUN mkdir -p /usr/src/app/
    COPY . /usr/src/app/
    WORKDIR /usr/src/app/
    
    RUN pip3 install jupyter
    RUN pip3 install pandas
    RUN jupyter nbconvert --to python Hello.ipynb
    
    CMD ["python", "Hello.py"]
> docker run -v /Scripts:/usr/src/app app
python: can't open file 'Hello.py': [Errno 2] No such file or directory

You are OVERWRITING the directory.您正在覆盖目录。

You have first said "Copy the application and source code to /usr/src/app . Then said, "ignore that, overwrite the entire /usr/src/app directory with /Scripts by using -v /Scripts:/usr/src/app .您首先说“将应用程序和源代码复制到/usr/src/app 。然后说,”忽略这一点,使用-v /Scripts:/usr/src/app/Scripts覆盖整个/usr/src/app目录-v /Scripts:/usr/src/app


To fix.修理。

  1. Send the volume to a DIFFERENT directory.将卷发送到不同的目录。 /mnt is perfect for that. /mnt是完美的。
  2. Your docker container only knows about the files IN the container.您的 docker 容器只知道容器中的文件。 Since you are sending the volume to /mnt , you must change your C:\\Scripts\\ to /mnt .由于您将卷发送到/mnt ,您必须将C:\\Scripts\\更改为/mnt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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