![](/img/trans.png)
[英]How do I increase the cell width of the Jupyter/ipython notebook in my browser?
[英]How do I configure jupyter notebook for having a pre loaded cell with certain imports without using ipython?
我想每次启动笔记本时在笔记本的第一个单元中导入某些库并定义某些功能。 就我而言,我为此使用了一个Docker容器。 经过几个链接和答案( https://vivekbharadwaj.github.io/data%20science/jumpstart-your-Jupyter-notebook-analysis-with-pre-loaded-cells/ )后,我无法设置笔记本因为我有某些错误。
这些是命令:
# Python3 Kernel for JuPyter notebooks
RUN python3 -m pip install ipykernel
RUN python3 -m ipykernel install --user
RUN python3 -m pip install jupyter_contrib_nbextensions
RUN mkdir -p /usr/local/airflow/.local/share/jupyter/preload_import_code
RUN echo "define([ 'base/js/namespace' ], function( Jupyter ) { function load_ipython_extension() { if (Jupyter.notebook.get_cells().length===1){ //change this piece of code to what you want Jupyter.notebook.insert_cell_above('code', 0).set_text(\"import os, sys;\"); } } return { load_ipython_extension: load_ipython_extension }; });" >> /usr/local/airflow/.local/share/jupyter/preload_import_code/main.js
RUN jupyter nbextension enable --sys-prefix preload_import_code/main
使用当前类似的答案和问题,由于错误或因为使用了ipython
,我无法进行配置。
运行时,在此步骤中出现以下错误:
Step 36/41 : RUN jupyter nbextension enable --sys-prefix preload_import_code/main
---> Running in c56e28731e36
Enabling notebook extension preload_import_code/main...
- Validating: problems found:
- require? X preload_import_code/main
Removing intermediate container c56e28731e36
---> ea0c6505dd57
我在这里使用了另一种特定于ipython
方法( https://stackoverflow.com/a/56216780/10834788 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.