我正在使用ipython笔记本执行我的第一步,并将其成功安装在我的远程服务器上(通过SSH),并使用以下命令启动它:
ipython notebook --ip='*' ---pylab=inline --port=7777
Run Code Online (Sandbox Code Playgroud)
然后我检查了http://myserver.sth:7777 /并且笔记本运行正常.然后我想关闭与服务器的SSH连接并让ipython在后台运行.当我这样做时,我无法连接到myserver.sth:7777.一旦我通过SSH再次连接到远程服务器,我就可以再次连接到笔记本电脑.然后我尝试使用screen启动ipython:我创建了一个新的屏幕screen -S ipy,我开始上面的ipython笔记本,我曾经Ctrl+A,D分离屏幕并退出到TTY.我仍然可以远程连接到笔记本电脑.然后我关闭了SSH连接,404 NOT FOUND当我尝试访问我之前存储的笔记本时遇到错误,我无法在http://myserver.sth:7777 /的笔记本列表中看到它.我试图创建一个新的笔记本,但我有一个500 Internal Server Error.
我也尝试过ipython notebook使用和不使用sudo.
有任何想法吗?
我想在IPython笔记本中心标题单元格.
我知道可以通过编写HTML来创建居中的标题,但是在使用目录时我无法获得对单元格的引用(nbtoc ext.)
有没有办法用带有居中文本的引用或标题单元格编写HTML标题?
谢谢!
在IPython笔记本中,我在单元格中输入以下代码:
from IPython.display import HTML
HTML("""<div>One</div>""")
HTML("""<div>Two</div>""")
Run Code Online (Sandbox Code Playgroud)
为什么输出单元只包含第二个div?
编辑.@Dunno已经展示了如何将所有html放入一个HTML()并且两个元素都被渲染,但我仍然不明白发生了什么.这是一个更一般的情况:
当我在输入单元格中输入它时:
1
2
3
Run Code Online (Sandbox Code Playgroud)
输出是
3
Run Code Online (Sandbox Code Playgroud)
但如果我输入以下内容:
print 1
print 2
print 3
Run Code Online (Sandbox Code Playgroud)
然后我得到这个输出:
1
2
3
Run Code Online (Sandbox Code Playgroud)
有什么不同?当我不使用print语句时,IPython笔记本只评估最后一个语句吗?或者每个后续评估都会覆盖前一个评估?
我正在尝试学习如何使用ipdb调试器.我插入一个断点,然后输入continue我从一个断点前进到另一个断点.如果我想打印变量的值一段时间我在两个断点之间执行的一半,我怎么能用ipdb/pdb做这个?我试过print和pprint但没有出现.

假设我使用Ipython笔记本与Scipy工厂进行了复杂的数值计算。现在,我想从Javascript中的代码(仍在IPYNB中)调用Scipy计算得出的变量。
以下是我愿意完成的工作的简单说明:
# Get a vector of 4 normal random numbers using numpy - the variable 'rnd'
import numpy as np
mu, sig = 0.05, 0.2
rnd = np.random.normal(loc=mu, scale=sig, size=4)
Run Code Online (Sandbox Code Playgroud)
现在,我想rnd在Javascript中使用上面的变量,用于说明目的:
%%javascript
element.append(rnd);
Run Code Online (Sandbox Code Playgroud)
上面的行返回消息错误:ReferenceError: rnd is not defined。
然后,如何在Ipython Notebook中的javascript代码中使用python变量?
我正在尝试在ipython笔记本中打印df,但它不会将其打印为表格.
data = {'year': [2010, 2011, 2012, 2011, 2012, 2010, 2011, 2012],
'team': ['Bears', 'Bears', 'Bears', 'Packers', 'Packers', 'Lions', 'Lions', 'Lions'],
'wins': [11, 8, 10, 15, 11, 6, 10, 4],
'losses': [5, 8, 6, 1, 5, 10, 6, 12]}
football = pd.DataFrame(data, columns=['year', 'team', 'wins', 'losses'])
print football
Run Code Online (Sandbox Code Playgroud)
产量
year team wins losses
0 2010 Bears 11 5
1 2011 Bears 8 8
2 2012 Bears 10 6
3 2011 Packers 15 1
4 2012 Packers 11 5
5 2010 …Run Code Online (Sandbox Code Playgroud) 我试图从IPython笔记本中导出一些图。搜索我已经找到了这个问题,可以对问题进行排序。正如答案中指出的那样,我必须savefig在与plot命令相同的单元格中进行调用。
我的问题是,为什么这些呼叫必须在同一单元格中?我的笔记本服务器以--pylab=inline模式启动。如果不是内联,则可以很好地导出绘图。
我的目标是在IPython笔记本中显示决策树.我的问题是,当我尝试渲染它时,它打开一个新窗口,而我希望它是内联的(如matplotlib图).
这是我使用的代码:
def show_tree(decisionTree, out_file, feature_names):
out_file = 'viz_tree/' + out_file
export_graphviz(decisionTree, out_file=out_file, feature_names=feature_names)
dot = ''
with open(out_file, 'r') as file:
for line in file:
dot += line
dot = Source(dot)
return dot
decisionTree.fit(inputs, outputs)
d = show_tree(decisionTree, 'tree.dot', col_names)
d.render(view=True)
Run Code Online (Sandbox Code Playgroud)
我知道因为这个例子可以这样做.
你知道我怎么能这样做吗?
我正在使用Ubuntu 14.04 LTSAnaconda python安装:
Python 3.5.1 :: Anaconda 2.4.1(64位)
我正在尝试使用此配方在我的ipython笔记本中启用C++交互式编译:
import IPython.core.magic as ipym
@ipym.magics_class
class CppMagics(ipym.Magics):
@ipym.cell_magic
def cpp(self, line, cell=None):
"""Compile, execute C++ code, and return the standard output."""
# Define the source and executable filenames.
source_filename = 'temp.cpp'
program_filename = 'temp.exe'
# Write the code contained in the cell to the C++ file.
with open(source_filename, 'w') as f:
f.write(cell)
# Compile the C++ code into an executable.
compile = self.shell.getoutput("g++ {0:s} -o {1:s}".format( …Run Code Online (Sandbox Code Playgroud) python ipython ipython-notebook ipython-magic jupyter-notebook
我正在尝试制作一个交互式情节,jupyter notebook但我不确切知道如何实现它.拥有一个数据帧我运行一个简单的回归,然后绘制,以查看分布.我希望能够悬停其中一个点并获得与此点相关的数据.我怎样才能做到这一点?现在我只能制作静态情节

import pandas as pd
from sklearn import linear_model
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
net = pd.read_csv("network_ver_64.csv")
net = net[net.AWDT12 > 0]
x = net.LOAD_DAILY.values
y = net.AWDT12.values
x_lenght = int(x.shape[0])
y_lenght = int(y.shape[0])
x = x.reshape(x_lenght, 1)
y = y.reshape(y_lenght,1)
regr = linear_model.LinearRegression()
regr.fit(x, y)
plt.scatter(x, y, color='black')
plt.plot(x, regr.predict(x), color='blue', linewidth=1)
plt.xticks(())
plt.yticks(())
plt.show()
Run Code Online (Sandbox Code Playgroud) ipython-notebook ×10
python ×7
ipython ×5
matplotlib ×2
pandas ×2
dataframe ×1
graphviz ×1
pdb ×1
plot ×1