<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font size="4">Hi Matthias<br><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><font size="4">I have checked my clipboard.py file in /usr/lib/python2.7/dist-packages/IPython/lib/. There is a new corresponding .pyc, so I guess its staleness is not an option to explain the error. However, I verified that in the clipboard.py file itself there is an additional line as compared to the link you gave; it is in the fucntion definition tkinter_clipboard_get, which is the one which must be used, because I am in a Linux box (Debian). Explicitly, this (small) function definition, inside clipboard.py, reads:<br>
<br>def tkinter_clipboard_get():<br>    """ Get the clipboard's text using Tkinter.<br><br>    This is the default on systems that are not Windows or OS X. It may<br>    interfere with other UI toolkits and should be replaced with an<br>
    implementation that uses that toolkit.<br>    """<br>    try:<br>        import Tkinter<br>    except ImportError:<br>        from IPython.utils import py3compat<br>        raise TryNext("Getting text from the clipboard on this platform "<br>
                      "requires the %s-tk package." % ("python3" if py3compat.PY3 else "python"))<br>    root = Tkinter.Tk()<br>    root.withdraw()<br>    text = root.clipboard_get()<br>    root.destroy()<br>
    text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)<br>    return text<br><br></font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><font size="4">The additional line, nonexistent in the link you gave, is the one "from IPython.utils import py3compat". I have now commented it out and everything seems to be working fine again! Thanks.</font><br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jan 19, 2014 at 3:47 PM, Matthias BUSSONNIER <span dir="ltr"><<a href="mailto:bussonniermatthias@gmail.com" target="_blank">bussonniermatthias@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
You can open an issue on github, but the py3compat import is here on 1.1.0:<br>
<br>
<a href="https://github.com/ipython/ipython/blob/rel-1.1.0/IPython/lib/clipboard.py#L7" target="_blank">https://github.com/ipython/ipython/blob/rel-1.1.0/IPython/lib/clipboard.py#L7</a><br>
<br>
Could you have stale .pyc cache or things like that ?<br>
<br>
--<br>
M<br>
<br>
Le 19 janv. 2014 à 15:00, Mauricio Calvao a écrit :<br>
<div><div class="h5"><br>
> Hi there,<br>
><br>
> I used to have a working ipython environment, including the qtconsole and notebook, besides the command line. After a dist-upgrade of my Debian, everything still seems to be working fine, except for the paste magic command, which issues the message:<br>

><br>
> In [1]: paste<br>
> ---------------------------------------------------------------------------<br>
> UnboundLocalError                         Traceback (most recent call last)<br>
> <ipython-input-1-84f91d8a6054> in <module>()<br>
> ----> 1 get_ipython().magic(u'paste ')<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)<br>
>    2170         magic_name, _, magic_arg_s = arg_s.partition(' ')<br>
>    2171         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)<br>
> -> 2172         return self.run_line_magic(magic_name, magic_arg_s)<br>
>    2173<br>
>    2174     #-------------------------------------------------------------------------<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)<br>
>    2091                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals<br>
>    2092             with self.builtin_trap:<br>
> -> 2093                 result = fn(*args,**kwargs)<br>
>    2094             return result<br>
>    2095<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.pyc in paste(self, parameter_s)<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)<br>
>     189     # but it's overkill for just that one bit of state.<br>
>     190     def magic_deco(arg):<br>
> --> 191         call = lambda f, *a, **k: f(*a, **k)<br>
>     192<br>
>     193         if callable(arg):<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.pyc in paste(self, parameter_s)<br>
>     216             return<br>
>     217         try:<br>
> --> 218             block = self.shell.hooks.clipboard_get()<br>
>     219         except TryNext as clipboard_exc:<br>
>     220             message = getattr(clipboard_exc, 'args')<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/core/hooks.pyc in __call__(self, *args, **kw)<br>
>     130             #print "prio",prio,"cmd",cmd #dbg<br>
>     131             try:<br>
> --> 132                 return cmd(*args, **kw)<br>
>     133             except TryNext as exc:<br>
>     134                 last_exc = exc<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/core/hooks.pyc in clipboard_get(self)<br>
>     221     for func in chain:<br>
>     222         dispatcher.add(func)<br>
> --> 223     text = dispatcher()<br>
>     224     return text<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/core/hooks.pyc in __call__(self, *args, **kw)<br>
>     130             #print "prio",prio,"cmd",cmd #dbg<br>
>     131             try:<br>
> --> 132                 return cmd(*args, **kw)<br>
>     133             except TryNext as exc:<br>
>     134                 last_exc = exc<br>
><br>
> /usr/lib/python2.7/dist-packages/IPython/lib/clipboard.pyc in tkinter_clipboard_get()<br>
>      51     text = root.clipboard_get()<br>
>      52     root.destroy()<br>
> ---> 53     text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)<br>
>      54     return text<br>
>      55<br>
><br>
> UnboundLocalError: local variable 'py3compat' referenced before assignment<br>
><br>
> In [2]: can't invoke "event" command:  application has been destroyed<br>
>     while executing<br>
> "event generate $w <<ThemeChanged>>"<br>
>     (procedure "ttk::ThemeChanged" line 6)<br>
>     invoked from within<br>
> "ttk::ThemeChanged"<br>
><br>
><br>
> In [2]:<br>
><br>
><br>
><br>
> after I try to paste the simple line:<br>
><br>
>    import numpy as np<br>
><br>
><br>
> My Python and Ipython versions are:<br>
><br>
> orca@andromeda:~$ ipython<br>
> Python 2.7.6 (default, Jan 11 2014, 14:34:26)<br>
> Type "copyright", "credits" or "license" for more information.<br>
><br>
> IPython 1.1.0 -- An enhanced Interactive Python.<br>
> ?         -> Introduction and overview of IPython's features.<br>
> %quickref -> Quick reference.<br>
> help      -> Python's own help system.<br>
> object?   -> Details about 'object', use 'object??' for extra details.<br>
><br>
><br>
> Any suggestions please?<br>
><br>
> Regards!<br>
><br>
><br>
> --<br>
> #######################################<br>
> Prof. Mauricio Ortiz Calvao<br>
> Federal University of Rio de Janeiro<br>
> Institute of Physics, P O Box 68528<br>
> CEP 21941-972 Rio de Janeiro, RJ<br>
> Brazil<br>
><br>
> Email: <a href="mailto:orca@if.ufrj.br">orca@if.ufrj.br</a><br>
> Phone: (55)<a href="tel:%2821%2925627483" value="+552125627483">(21)25627483</a><br>
> Homepage: <a href="http://www.if.ufrj.br/~orca" target="_blank">http://www.if.ufrj.br/~orca</a><br>
> #######################################<br>
</div></div>> _______________________________________________<br>
> IPython-dev mailing list<br>
> <a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>#######################################<br>Prof. Mauricio Ortiz Calvao<br>Federal University of Rio de Janeiro<br>Institute of Physics, P O Box 68528<br>CEP 21941-972 Rio de Janeiro, RJ<br>
Brazil<br><br>Email: <a href="mailto:orca@if.ufrj.br" target="_blank">orca@if.ufrj.br</a><br>Phone: (55)(21)25627483<br>Homepage: <a href="http://www.if.ufrj.br/~orca" target="_blank">http://www.if.ufrj.br/~orca</a><br>#######################################
</div>