ipython

Watch long term process in Ipython notebook

非 Y 不嫁゛ 提交于 2019-12-23 03:15:38
问题 For now, after reconnect ipython notebook is not able to print any output from running kernel. I tried following work-around: import sys, time with open('foo.log','w') as sys.stdout: for i in range(5): print i time.sleep(1) everything is nice, I can see the process with tail -f foo.log , but at the end whole thing crashes and I get following error: ERROR:tornado.general:Uncaught exception, closing connection. Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/zmq

Object string representation in Python/IPython shell

我怕爱的太早我们不能终老 提交于 2019-12-23 02:53:17
问题 I have a friendly month class I enjoy that returns an ugly robot friendly string: In [3]: d = date(2010, 1, 31) In [4]: m = Month(d) In [5]: m Out[5]: <dfa.date_range.Month at 0x7fb4d5793cc0> I want m to show something like 1-31-2010 . I try using unicode and str , just like in django, no dice: class Month(object): def __init__(self, dateobj): self.dateobj = dateobj # def __unicode__(self): # return self.dateobj def __str__(self): return self.dateobj @property def first_day(self): return self

convert ipython notebook to mediawiki

≡放荡痞女 提交于 2019-12-22 18:02:09
问题 I would like to convert an ipython notebook to mediawiki markup. I had two ideas how to do that: Customize an export for the nbconvert tool. Export to LaTeX first and then use pandoc to convert it to mediawiki markup. I couldn't find anything on the first option. The problem for the second option is that LaTeX output puts in a lot of custom commands which are not converted into <source lang='python'> ... </source> tags correctly. Does anybody have a good idea? 回答1: you can probably pitch-in

ipython: command not found on OSX

无人久伴 提交于 2019-12-22 14:16:38
问题 I installed the python scientific environment (numpy, scipy, matplotlib, pandas, ipython) a while ago on OSX using brew and either pip or easy_install (or the 2 of them, I don't remember). Now if try to run ipython I get: -> ipython -bash: ipython: command not found Then I did: -> sudo find . -iname "*ipython*" Password: find: ./dev/fd/3: Not a directory find: ./dev/fd/4: Not a directory ./Users/jfk/.ipython ./usr/local/Cellar/matplotlib/1.2.0/lib/python2.7/site-packages/matplotlib/sphinxext

How to interrupt native extension code without killing the interpreter?

天大地大妈咪最大 提交于 2019-12-22 12:57:27
问题 I am working on a project which combines high-performance algorithms written in C++ with a Python interface. C++ classes and functions are wrapped and exposed to Python via the Cython compiler. Suppose I call a long running native function from the Python interpreter (my preferred one is IPython). Is it somehow possible to interrupt or abort the execution of that code without killing the interpreter? 回答1: Here is a possible implementation using multiprocessing as suggested by Ricardo C.,

IPython ends input of indented blocks after first newline

左心房为你撑大大i 提交于 2019-12-22 11:25:32
问题 In IPython, I can't enter in a multiline indented block; it ends input (switches from the ...: prompt to the next In [x] ), as soon as I hit enter. For example, I'm trying to write an example implementation of Newton's method for a demonstration. I can only write the first line before it returns me to, so all I can type into IPython is this: In [3]: def newton(x0, fn, epsilon=0.00001): ...: x1 = x0 - fn.evalf(subs={'x': x0}) / fn.diff().evalf(subs={'x': x0}) In [4]: I'm using Python 3.6.6,

How to run ipython from venv?

筅森魡賤 提交于 2019-12-22 10:46:11
问题 My ipython works okay, but when I try to open ipython console from venv I am getting: Traceback (most recent call last): File "/usr/bin/ipython3", line 4, in <module> from IPython import start_ipython ImportError: No module named 'IPython' Any ways to do this? 回答1: Did you by any chance create the venv with the --system-site-packages flag and install ipython with pip ? This combination is broken in my experience ( Python 3.6.2 , pip 9.0.1 ). Two workarounds are: Use virtualenv instead of venv

iPython- Is there a way to answer “y” to (or ignore) all y/n prompts?

夙愿已清 提交于 2019-12-22 10:36:28
问题 So I have an ipython notebook that has a lot of large variables, and at one point I want to get rid of all the ones I'm done with. I'm using %reset_selective variablename to clear each one, but there's 60 of these variables and when I run the block that has all 60 prompts, it asks me to enter y/n for every clear. "Once deleted, variables cannot be recovered. Proceed (y/[n])?" Is there a way I can answer "y" for all of them at once, or to skip the prompt altogether? 回答1: Reading from here:

ImportError: No module named IPython.paths when running jupyter notebook?

亡梦爱人 提交于 2019-12-22 08:42:20
问题 I installed jupyter via: /usr/local/opt/python/bin/python2.7 -m pip install jupyter this install ipython version 4.1.2. However, when I run jupyter notebook, I get: Traceback (most recent call last): File "/usr/local/bin/jupyter-notebook", line 7, in <module> from notebook.notebookapp import main File "/Library/Python/2.7/site-packages/notebook/notebookapp.py", line 83, in <module> from IPython.paths import get_ipython_dir ImportError: No module named IPython.paths yet, when I run from

How can I interrupt the IPython interpreter as opened in emacs?

半世苍凉 提交于 2019-12-22 08:19:32
问题 Let's say I accidentally evaluate an enormous variable--a list with a ba-jillion elements, or whatever. As they scroll down my screen and my computer crawls to a halt, is there a good way to interrupt this without killing my *Python* buffer? I'm using IPython via python-mode.el and ipython.el in emacs24 on Mac OS X Leopard-- Thoughts appreciated, a. 回答1: I usually C-c until it stops... and it usually works... 回答2: you could file a feature request at http://launchpad.net/python-mode asking for