pandas: Unable to import pandas when using the gtk3 backend in ipython
In [1]: %matplotlib gtk3
In [2]: import pandas
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-2-38d4b0363d82> in <module>()
----> 1 import pandas
~/.local/lib/python3.6/site-packages/pandas/__init__.py in <module>()
56
57 from pandas.util._print_versions import show_versions
---> 58 from pandas.io.api import *
59 from pandas.util._tester import test
60 import pandas.testing
~/.local/lib/python3.6/site-packages/pandas/io/api.py in <module>()
17 from pandas.io.stata import read_stata
18 from pandas.io.pickle import read_pickle, to_pickle
---> 19 from pandas.io.packers import read_msgpack, to_msgpack
20 from pandas.io.gbq import read_gbq
21
~/.local/lib/python3.6/site-packages/pandas/io/packers.py in <module>()
66
67 from pandas.io.msgpack import Unpacker as _Unpacker, Packer as _Packer, ExtType
---> 68 from pandas.util._move import (
69 BadMove as _BadMove,
70 move_into_mutable_buffer as _move_into_mutable_buffer,
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 3: invalid start byte
If I use tk or qt instead, this doesn’t happen.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 33 (12 by maintainers)
I was having the same problem of you, but without use matplotlib directly.
I was using graph_tool, which has a draw module that imports gtk internally), and pandas. I just have changed the order that I imported the libs.
My code before the workaround:
My code after the workaround:
So, I think that you should try to import pandas before and, set the matplotlib backend after.
Importing Glib instead is ok:
Also Gdk works. The problem triggers as soon as
class Widget(Gtk.Widget):is left ingi/overrides/Gtk.py. HereGtk = get_introspection_module('Gtk')whereI can leave only
in the entire
Gtk.pymodule and the problem still happens. I’ve instrumented every method of IntrospectionModule and none of them is called just before the error occurs.Clearly the problem is very localized, we’ve now come to a point where no element can be removed without losing the ability to reproduce the error. Just three lines of the entire Gtk.py module get us into trouble.
OTOH the utf8 aspect could be unrelated to the real problem. Maybe something binary or ill-codified is being written to the terminal thus obfuscating the real nature of the problem.
Finally, at the point of the error the exception shows this trace: