问题
In jupyter-lab I can use the magic command %notebook $output_file_path
to save the history notebook as a jupyter notebook. When I am working with Google Colab (mounting Google Drive) the path of my notebook folder is something like:
root_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/'
The problem is that, as I try to save the notebook history, the space between "My" and "Drive" makes the magic command fail
output_file_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/nb_history.ipynb'
%notebook $output_file_path
with the following error:
UsageError: unrecognized arguments: Drive/Colab Notebooks/my_working_folder/nb_history.ipynb
I tried replacing the spaces with "\"
or "\\"
or "\ "
or "\\ "
with no success. I also tried to "embed" the path string into quotes like
output_file_path = '"gdrive/My Drive/Colab Notebooks/my_working_folder/nb_history.ipynb"'
with no success either, getting a different error:
FileNotFoundError: [Errno 2] No such file or directory: '"gdrive/My Drive/Colab Notebooks/my_working_folder/nb_history.ipynb"'
Is there a workaround I can exploit to use the %notebook
magic?
来源:https://stackoverflow.com/questions/60449515/ipython-magic-command-notebook-does-not-work-when-spaces-are-present-in-path-g