[IPython-User] Warning when running code with 'import gtk'

MinRK benjaminrk@gmail....
Mon Nov 14 16:27:55 CST 2011


On Mon, Nov 14, 2011 at 13:57, Alejandro Weinstein <
alejandro.weinstein@gmail.com> wrote:

> Hi:
>
> I get a warning when I use IPython to run a script that import the gtk
> module. I have the following file:
>
> ###### foo.py #######
> import gtk
> ### end of file #####
>
> If I do
>
> $ ipython foo.py
>
> or
>
> In [1]: %run foo.py
>
> I get the warning
>
> /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:54: Warning:
> ignoring sys.argv: it must be a list of strings
>  _gtk.init_check()
>
> Running the script with the standard python interpreter ($ python
> foo.py) produce no warning. Also, if I do the 'import gtk' inside
> IPython (instead of running the script with %run), I get no warning.
>
> I have a fresh install of Lubuntu 10.10 and IPython 0.11 (installed using
> pip).
>
> Any idea about how to avoid the warning?
>

This is a bug in 0.11, where we allowed sys.argv to be unicode strings, and
has been fixed in master by PR #898<https://github.com/ipython/ipython/pull/898>
.

It should be fairly easy to backport the fix to 0.11 (not quite trivial, as
the py3compat file where the cast_bytes function is defined was introduced
post-0.11, but it is a tiny function), but If you use master, it should
work.  I can reproduce the warning on 0.11, and do not see it on master.

A one-liner to install a current snapshot of IPython master with
pip/easy_install:

$> pip install [--user] https://github.com/ipython/ipython/tarball/master

-MinRK


>
> Alejandro.
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20111114/9a00ad32/attachment.html 


More information about the IPython-User mailing list