我正在尝试从命令行运行jupyter notebook的所有单元。对于该任务,我已完成:
jupyter nbconvert --inplace --execute myNotebook.ipynb.
现在的问题是我的脚本包含Plotly库中的一些图,然后当我使用jupyter的界面再次打开笔记本时,图为空白。我使用了很多选项,例如:
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
%matplotlib inline
¿有人对这个问题有任何想法吗?
谢谢
我添加了脚本的一部分以帮助您。
import pandas as pd
import plotly
from plotly.offline import init_notebook_mode, iplot
import plotly.graph_objects as go
from datetime import datetime
init_notebook_mode(connected=True)
df = pd.DataFrame({'one' : pd.Series([10, 20, 30, 40]),'two' : pd.Series([10, 20, 30, 40])})
fig = go.Figure()
fig.add_trace(go.Scatter(x=df.one,y=df.two))
fig.update_layout(xaxis_range=[min(df.one),max(df.one)])
iplot(fig)
print(datetime.now())
您可以通过两步来解决此问题
您的笔记本不受信任存在与密谋有关的问题,请信任您的笔记本
jupyter trust myNotebook.ipynb
现在从命令行运行笔记本电脑
jupyter nbconvert --inplace --execute myNotebook.ipynb.
您也可以看一下related