标签: ipython

如何在emacs中清除ipython缓冲区?

我在emacs缓冲区中使用运行和交互式ipython shell ipython.el.我想知道是否有办法清除屏幕?由于它没有在终端上运行,所以import os; os.system('CLS')技巧不起作用.谢谢.

emacs ipython

4
推荐指数
2
解决办法
1473
查看次数

使用glob样式扩展从ipython运行?

在ipython(0.10.2)中,我想运行bash shell样式(或glob.glob)扩展.我想做类似这样的事情,并且如果我在bash中那样扩展出来的话.这可能吗?

filenames = !ls *.sbet
run sbet.py $filenames
# fails because filenames is a list

# or the simpler case:
run sbet.py *.sbet
# failes with "*.sbet" being directly passed in without being expanded.
Run Code Online (Sandbox Code Playgroud)

建议?谢谢!

glob ipython

4
推荐指数
1
解决办法
631
查看次数

libedit/readline与OS X 10.7 Lion上的ipython 3.2.2冲突

我一直在尝试在运行Lion的mac上设置ipython 3(运行2.7正常),但似乎无法摆脱以下错误:

192:~ mlauria$ /Library/Frameworks/Python.framework/Versions/3.2/bin/ipython3
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages\
/IPython/utils/rlineimpl.py:96: RuntimeWarning: Leopard libedit detected - \
readline will not be well behaved including some crashes on tab completion, and \
incorrect history navigation. It is highly recommended that you install readline,\
which is easy_installable with: 'easy_install readline'
  RuntimeWarning)
Python 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59)
Run Code Online (Sandbox Code Playgroud)

easy_install readline在ipython 2.7上正确地解决了这个问题,但是这并没有修复3.2.

python readline ipython easy-install python-3.x

4
推荐指数
1
解决办法
1744
查看次数

python pdb:异常捕获后恢复代码执行?

如果我在ipython %pdb启用魔法的情况下运行代码并且代码抛出异常,是否有任何方法可以告诉代码继续执行?

例如,说例外是a ValueError: x=0 not allowed.我可以在pdb中设置x=1并允许代码继续(恢复)执行吗?

ipython pdb

4
推荐指数
1
解决办法
2780
查看次数

启动IPython

我想在已经安装了Python 2.7的Windows XP计算机上运行IPython(版本0.12).

我通过Windows二进制安装程序安装,但安装后IPython没有显示在菜单中,并且无法使用命令窗口启动,尽管在C:路径中创建了一个IPython文件夹.

我也尝试了其他下载选项(tar.gz和zip),但又失败了.

有人可以帮忙吗?

ipython

4
推荐指数
1
解决办法
5932
查看次数

IPython.parallel模块中的内存泄漏?

我正在使用IPython.parallel来处理集群上的大量数据.我运行的远程功能如下:

def evalPoint(point, theta):
    # do some complex calculation
    return (cost, grad)
Run Code Online (Sandbox Code Playgroud)

这个函数调用它:

def eval(theta, client, lview, data):
    async_results = []
    for point in data:
        # evaluate current data point
        ar = lview.apply_async(evalPoint, point, theta)
        async_results.append(ar)

    # wait for all results to come back
    client.wait(async_results)

    # and retrieve their values
    values = [ar.get() for ar in async_results]

    # unzip data from original tuple
    totalCost, totalGrad = zip(*values)

    avgGrad =  np.mean(totalGrad, axis=0)
    avgCost = np.mean(totalCost, axis=0)

    return (avgCost, avgGrad)
Run Code Online (Sandbox Code Playgroud)

如果我运行代码:

client …
Run Code Online (Sandbox Code Playgroud)

parallel-processing memory-leaks ipython

4
推荐指数
1
解决办法
1570
查看次数

在IPython笔记本中操纵内联图

我正在使用IPython 0.12.1笔记本从Windows机器连接到运行IPython内核的Linux服务器.由于Linux机器没有安装X-Server,我使用以下配置:

IPKernelApp.pylab = 'inline'

它以内联方式显示数字.

一旦在笔记本中绘制数字,IPython就会关闭它们.那么如何编辑刚绘制的图形呢?喜欢添加标题.对于我的情况,绘图过程需要一段时间,我希望能够在保存它之前使用该图来玩,而无需重绘它.

我试着保存一个手柄,并使用它,但我没有成功.

matplotlib ipython

4
推荐指数
1
解决办法
2392
查看次数

如何撤消iPython shell中的输入(不是命令输出)

在iPython中是否有用于撤消键入的键盘命令?注意:我不是在讨论撤消已执行命令的结果.

假设我将一些变量名称作为参数复制并粘贴到一个长函数调用中,然后意识到它们是错误的参数.我可以使用等效的ctrl-z或者撤消粘贴操作吗?

Ctrl-z会杀死iPython会话,因此不推荐使用.

shell undo ipython

4
推荐指数
2
解决办法
3301
查看次数

如何将ipython从0.12升级到0.13?

我在Mac Lion OS上使用最新的免费版Enthought包.ipython附带的包装是0.12.如何将其升级到0.13?

当我按照说明操作并运行以下命令时

sudo easy_install ipython[zmq,qtconsole,notebook,test]
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

Searching for ipython[zmq,qtconsole,notebook,test]
Best match: ipython 0.12.1
Adding ipython 0.12.1 to easy-install.pth file

Using /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages
Processing dependencies for ipython[zmq,qtconsole,notebook,test]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/easy_install", line 10, in 
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1915, in main
    with_ei_usage(lambda:
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1896, in with_ei_usage
    return f()
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1919, in 
    distclass=DistributionWithoutHelpCommands, **kw
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/distutils/dist.py", line 972, in run_command …

ipython

4
推荐指数
2
解决办法
1万
查看次数

IPython并行计算命名空间问题

我一直在阅读和重新阅读IPython文档/教程,我无法弄清楚这段特殊代码的问题.看起来这个函数dimensionless_run对于传递给每个引擎的命名空间是不可见的,但我很困惑,因为函数是在__main__全局命名空间中定义的,并且清晰可见.

wrapper.py:

import math, os

def dimensionless_run(inputs):
    output_file = open(inputs['fn'],'w')
    ...
    return output_stats

def parallel_run(inputs):
    import math, os  ## Removing this line causes a NameError: global name 'math'
                     ## is not defined.
    folder = inputs['folder']
    zfill_amt = int(math.floor(math.log10(inputs['num_iters'])))
    for i in range(inputs['num_iters']):
        run_num_str = str(i).zfill(zfill_amt)
        if not os.path.exists(folder + '/'):
            os.mkdir(folder)
        dimensionless_run(inputs)
    return

if __name__ == "__main__":
    inputs = [input1,input2,...]
    client = Client()
    lbview = client.load_balanced_view()
    lbview.block = True
    for x in sorted(globals().items()):
        print x
    lbview.map(parallel_run,inputs) …
Run Code Online (Sandbox Code Playgroud)

python parallel-processing ipython nameerror

4
推荐指数
1
解决办法
2659
查看次数