Question re Subtle Diff between Embed and Breakpoint
2007-07-04 11:27:30 GMT
Hi, I'm preparing a presentation on the features of IPython and I'm stuck on one question. What is the difference (in capability) between: dropping into an IPShellEmbed(), poking some vars and then exiting the shell to let the program continue executing, setting a breakpoint using pdb at that same point, poking some vars and letting it continue running, enabling IPython's feature of sending uncaught exceptions into the debugger, placing an exception at that same code point, and upon hitting the exception, poking at some vars, I guess in this cast I cannot continue running though since Python exceptions are not recoverable. There seems to be a very subtle difference and I want to convey it accurately in my presentation (actually a screencast). Thanks, -Jeff
Various questions re: IPython on Windows
2007-07-13 18:58:36 GMT
I'm having a few problems and I don't know if these are bugs, or simply
user error. Any help would be appreciated. :)
1. When I try to run the %edit command, I always get the below error.
The error occurs *before* my editor has even launched!
Editing... done. Executing edited code...
Could not open file
<c:\docume~1\rsiebler\locals~1\temp\ipython_edit_zo5me2.py>
for safe execution.
WARNING: File not found. Did you forget to save?
2. When I try to use the %run command on a script, I always get this error:
In [3]: %run save_song_list.py
---------------------------------------------------------------------------
exceptions.SystemExit Traceback (most
recent call
last)
c:\temp\save_song_list.py
83 db.close()
84
---> 85 if __name__== '__main__': main()
86
87
c:\temp\save_song_list.py in main()
50 last_song = db['last_song']
51 if song in last_song:
(Continue reading)Re: Various questions re: IPython on Windows
2007-07-14 09:33:54 GMT
On 7/13/07, Robin Siebler <robinsiebler <at> 321.net> wrote: > 1. When I try to run the %edit command, I always get the below error. > The error occurs *before* my editor has even launched! What's in your EDITOR variable? > 2. When I try to use the %run command on a script, I always get this error: > > In [3]: %run save_song_list.py > --------------------------------------------------------------------------- > exceptions.SystemExit Traceback (most > recent call > last) > > c:\temp\save_song_list.py > 83 db.close() > 84 > ---> 85 if __name__== '__main__': main() > 86 > 87 > > c:\temp\save_song_list.py in main() > 50 last_song = db['last_song'] > 51 if song in last_song: > ---> 52 sys.exit() > 53 else: > 54 if len(last_song) == 3: > > SystemExit:(Continue reading)
Re: UNSUBSCRIBE
2007-07-20 16:32:20 GMT
On 7/20/07, Howey, David A <d.howey <at> imperial.ac.uk> wrote: > > > > please unsubscribe me Please unsubscribe yourself: http://projects.scipy.org//mailman/listinfo/ipython-user Thanks f
Re: Various questions re: IPython on Windows
2007-07-20 17:11:15 GMT
> What's in your EDITOR variable? I don't have one. It is launching notepad (well Notepad++ really) > Well, you do run sys.exit()... > >> AttributeError: 'module' object has no attribute 'clear_history' > > Do you have the latest pyreadline installed? pyreadline-1.4.4.win32.exe > >> >> 3. For pysh, if I try to use $var=cmd or $$var=cmd as shown in the docs, >> I get the following error: >> >> [Documents and Settings\rsiebler]|15> $foo = !dir > > It should be "foo = !dir", i.e. lose the $. Ok. I guess the docs are Linuxcentric. :p
Re: Various questions re: IPython on Windows
2007-07-20 18:07:58 GMT
On 7/20/07, Robin Siebler <robinsiebler <at> 321.net> wrote:
> > What's in your EDITOR variable?
> I don't have one. It is launching notepad (well Notepad++ really)
>
> > Well, you do run sys.exit()...
> >
> >> AttributeError: 'module' object has no attribute 'clear_history'
> >
> > Do you have the latest pyreadline installed?
> pyreadline-1.4.4.win32.exe
>
> >
> >>
> >> 3. For pysh, if I try to use $var=cmd or $$var=cmd as shown in the docs,
> >> I get the following error:
> >>
> >> [Documents and Settings\rsiebler]|15> $foo = !dir
> >
> > It should be "foo = !dir", i.e. lose the $.
>
> Ok. I guess the docs are Linuxcentric. :p
No, it's just that the $foo syntax is only activated in the 'pysh' old
profile, not in the newer 'sh' one:
IPython profile: pysh
fperez <at> planck[misc]|1> $foo = ls
fperez <at> planck[misc]|2> foo
<2> LSString (.p, .n, .l, .s available). Value:
addtest.txt
(Continue reading)Re: Various questions re: IPython on Windows
2007-07-21 18:15:58 GMT
> > What's in your EDITOR variable? > I don't have one. It is launching notepad (well Notepad++ really) There is something different about the way Notepad++ (and cream for gvim and some other editors I've tried) starts compared to plain old Notepad that makes ipy think the editor has already returned control. If you change the editor variable back to Notepad the %ed command will work. A substandard solution, I know, but the only one I've learned about so far. If cygwin is on the computer one can also use command line vi.exe which is at least smarter than notepad if not as convenient for those of us with a Windows background. cheers, -- -- -matt
problem with Ipython1 SAW and test library "py.test"
2007-07-27 15:06:44 GMT
Hello,
I'm used Ipython1 SAW since
some months , but now I obtain an error between Ipython1 and test
library "py.test" under Linux (and Windows also).
When I write in a python command prompt:
">>> import ipython1.kernel.api as kernel"
I have no error and I can use Ipython1
without error : )
But, I create a python test file test_WS_SessionManager.py which begin by
"import ipython1.kernel.api as kernel"
I write in a command prompt : "py.test test_WS_SessionManager.py", I obtain the error message that you can read in attached file: "error.txt"
(the error append with line: "from IPython.genutils import get_home_dir")
I also try to use Doctest, and to update my Ipython1 version, but I have also an error at these line :(
Although I search on internet, I don't solve this problem, so I need your help please.
Regards.
Vincent
# Make it easy to import extensions - they are always directly on pythonpath.
# Therefore, non-IPython modules can be added to Extensions directory
import os
sys.path.append(os.path.dirname(__file__) + "/Extensions")
# Define what gets imported with a 'from IPython import *'
__all__ = ['deep_reload','genutils','ipstruct','ultraTB','DPyGetOpt',
'Itpl','hooks','ConfigLoader','OutputTrap','Release','Shell',
'platutils','platutils_win32','platutils_posix','platutils_dummy',
'ipapi','rlineimpl', 'strdispatch']
# Load __all__ in IPython namespace so that a simple 'import IPython' gives
# access to them via IPython.<name>
glob,loc = globals(),locals()
for name in __all__:
> __import__(name,glob,loc,[])
[/usr/lib/python2.5/site-packages/IPython/__init__.py:60]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
$Id: genutils.py 2190 2007-03-30 18:35:46Z fperez $"""
#*****************************************************************************
# Copyright (C) 2001-2006 Fernando Perez. <fperez <at> colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#*****************************************************************************
from IPython import Release
__author__ = '%s <%s>' % Release.authors['Fernando']
__license__ = Release.license
#****************************************************************************
# required modules from the Python standard library
import __main__
import commands
import os
import re
import shlex
import shutil
import sys
import tempfile
import time
import types
import warnings
# Other IPython utilities
from IPython.Itpl import Itpl,itpl,printpl
from IPython import DPyGetOpt
from path import path
if os.name == "nt":
from IPython.winconsole import get_console_size
#****************************************************************************
# Exceptions
class Error(Exception):
"""Base class for exceptions in this module."""
pass
#----------------------------------------------------------------------------
class IOStream:
def __init__(self,stream,fallback):
if not hasattr(stream,'write') or not hasattr(stream,'flush'):
stream = fallback
self.stream = stream
self._swrite = stream.write
self.flush = stream.flush
def write(self,data):
try:
self._swrite(data)
except:
try:
# print handles some unicode issues which may trip a plain
# write() call. Attempt to emulate write() by using a
# trailing comma
print >> self.stream, data,
except:
# if we get here, something is seriously broken.
print >> sys.stderr, \
'ERROR - failed to write data to stream:', self.stream
def close(self):
pass
class IOTerm:
""" Term holds the file or file-like objects for handling I/O operations.
These are normally just sys.stdin, sys.stdout and sys.stderr but for
Windows they can can replaced to allow editing the strings before they are
displayed."""
# In the future, having IPython channel all its I/O operations through
# this class will make it easier to embed it into other environments which
# are not a normal terminal (such as a GUI-based shell)
def __init__(self,cin=None,cout=None,cerr=None):
self.cin = IOStream(cin,sys.stdin)
self.cout = IOStream(cout,sys.stdout)
self.cerr = IOStream(cerr,sys.stderr)
# Global variable to be used for all I/O
> Term = IOTerm()
[/usr/lib/python2.5/site-packages/IPython/genutils.py:91]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def __init__(self,cin=None,cout=None,cerr=None):
> self.cin = IOStream(cin,sys.stdin)
[/usr/lib/python2.5/site-packages/IPython/genutils.py:86]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def __init__(self,stream,fallback):
if not hasattr(stream,'write') or not hasattr(stream,'flush'):
stream = fallback
self.stream = stream
E self._swrite = stream.write
> AttributeError: DontReadFromInput instance has no attribute 'write'
[/usr/lib/python2.5/site-packages/IPython/genutils.py:54]
________________________________________________________________________________________
======================= tests finished: 1 failed in 0.05 seconds =======================
[root <at> localhost python]# clear
[root <at> localhost python]# py.test
================================= test process starts ==================================
executable: /usr/bin/python2.5 (2.5.0-final-0)
using py lib: /usr/lib/python2.5/site-packages/py <rev unknown>
test_WS_SessionManager.py - FAILED TO LOAD MODULE
________________________________________________________________________________________
_____________________________________ entrypoint: _____________________________________
def runtraced(self, colitem):
if self.shouldclose():
raise Exit, "received external close signal"
outcome = None
colitem.startcapture()
try:
self.start(colitem)
try:
try:
if colitem._stickyfailure:
raise colitem._stickyfailure
> outcome = self.run(colitem)
[/usr/lib/python2.5/site-packages/py/test/session.py:83]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def run(self, colitem):
if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item):
return
if isinstance(colitem, py.test.collect.Item):
colitem._skipbykeyword(self.config.option.keyword)
> res = colitem.run()
[/usr/lib/python2.5/site-packages/py/test/session.py:106]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def run(self):
> if getattr(self.obj, 'disabled', 0):
[/usr/lib/python2.5/site-packages/py/test/collect.py:351]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def obj(self):
try:
return self._obj
except AttributeError:
failure = getattr(self, '_stickyfailure', None)
if failure is not None:
raise failure[0], failure[1], failure[2]
try:
> self._obj = obj = self.fspath.pyimport()
[/usr/lib/python2.5/site-packages/py/test/collect.py:380]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def pyimport(self, modname=None, ensuresyspath=True):
""" return path as an imported python module.
if modname is None, look for the containing package
and construct an according module name.
The module will be put/looked up in sys.modules.
"""
if not self.check():
raise py.error.ENOENT(self)
#print "trying to import", self
pkgpath = None
if modname is None:
#try:
# return self._module
#except AttributeError:
# pass
pkgpath = self.pypkgpath()
if pkgpath is not None:
if ensuresyspath:
self._prependsyspath(pkgpath.dirpath())
pkg = __import__(pkgpath.basename, None, None, [])
if hasattr(pkg, '__package__'):
modname = pkg.__package__.getimportname(self)
assert modname is not None, "package %s doesn't know %s" % (
pkg.__name__, self)
else:
names = self.new(ext='').relto(pkgpath.dirpath())
names = names.split(self.sep)
modname = ".".join(names)
else:
# no package scope, still make it possible
if ensuresyspath:
self._prependsyspath(self.dirpath())
modname = self.purebasename
E mod = __import__(modname, None, None, ['__doc__'])
> File "/usr/share/python/test_WS_SessionManager.py", line 3
import ipythomport ipython1.kernel.api as kernel
^
SyntaxError: invalid syntax
[/usr/lib/python2.5/site-packages/py/path/local/local.py:418]
________________________________________________________________________________________
======================= tests finished: 1 failed in 0.03 seconds =======================
[root <at> localhost python]#
_______________________________________________ IPython-user mailing list IPython-user <at> scipy.org http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
New showmedo videos by Jeff Rush
2007-07-28 07:01:30 GMT
Hi everyone, Jeff Rush, the Python foundation advocacy lead, has just finished a new series of ShowMeDo videos about ipython: http://showmedo.com/videos/series?name=CnluURUTV I have to admit that I (re)learned a few tricks watching it :) I'd like to thank Jeff for the great work as well as Ian for ShowMeDo. And Ian has mentioned that there's a lot of interest in IPython videos, so if any of you has a bit of time, this would be a great little project with a guaranteed audience. Here's more info about the process: http://ipython.scipy.org/moin/ShowMeDo feel free to edit that page with new ideas of a topic you'd either want to see covered or would like to cover yourself (related to ipython, I'm not trying to hijack the showmedo system :) Cheers, f
RSS Feed