How to save a file into a directory in Jupyter notebook?

后端 未结 3 1291
梦如初夏
梦如初夏 2021-02-20 01:43

I invoke \"jupyter notebook\" under:

 [abigail@localhost anaconda3]$ jupyter notebook

By default, it saves to the directory of anaconda3/ with

相关标签:
3条回答
  • 2021-02-20 01:57

    There are two methods:
    1.You can use the magic command %notebook to save as ipynb

      %notebook "directory/to/file/filename.ipynb"     
    

    2.You can use the magic command %%writefile to save as py file

      %%writefile "directory/to/file/filename.py"
    

    In the second method, you should put this command at the top of the cell, otherwise it will throw an error.

    0 讨论(0)
  • 2021-02-20 02:10

    It is easiest to select a destination before you create a program using Jupyter Notebook; as then you do not run into this issue.

    However, since you have already made a program, one possible solution is to make a copy of the file, move it to your desired location, and then delete the old file. Before doing this, ensure that you have saved it first, otherwise data might be lost.

    0 讨论(0)
  • 2021-02-20 02:12

    You can save a notebook to a location of your choice by using the "File" -> "Download as" -> "Notebook (.ipynb)" option from the menu.

    Alternatively you can start your notebook server from a different directory and it will save all notebooks to that directory.

    A third option is to navigate to the directory you want the notebook to be saved to in the tree view "http://127.0.0.1:8888/tree" prior to creating the notebook.

    0 讨论(0)
提交回复
热议问题