Skip to content

import pandas as pd leads to UnicodeDecodeError #24473

Closed
@Jakob-S

Description

@Jakob-S

Code Sample, a copy-pastable example if possible

import gi
gi.require_version("Gtk", "3.0")
gi.require_version("WebKit2", "4.0")
from gi.repository import Gtk, GdkPixbuf, Gdk, WebKit2, GObject
from urllib import parse as urlparse
import os, sys
import sqlite3 as s
import pandas as pd
import requests
from xml.etree import ElementTree
import numpy as np
import folium

Problem description

When I try to debug my GUI, the following message is shown in stacktrace:

Traceback (most recent call last):
  File "./src/birdmap.py", line 27, in <module>
    import pandas as pd
  File "/home/rtfm/.local/lib/python3.7/site-packages/pandas/__init__.py", line 57, in <module>
    from pandas.io.api import *
  File "/home/rtfm/.local/lib/python3.7/site-packages/pandas/io/api.py", line 19, in <module>
    from pandas.io.packers import read_msgpack, to_msgpack
  File "/home/rtfm/.local/lib/python3.7/site-packages/pandas/io/packers.py", line 69, in <module>
    from pandas.util._move import (
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 2: invalid start byte

When I import it in python console, no error message is printed, but only If i import it while not using other libraries. It seems, that some of the mentioned libs crash pandas and indirectly also folium.

This is, what folium prints in terminal, but not at debugging:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rtfm/.local/lib/python3.7/site-packages/folium/__init__.py", line 8, in <module>
    import branca
  File "/home/rtfm/.local/lib/python3.7/site-packages/branca/__init__.py", line 5, in <module>
    import branca.colormap as colormap
  File "/home/rtfm/.local/lib/python3.7/site-packages/branca/colormap.py", line 14, in <module>
    from branca.element import ENV, Figure, JavascriptLink, MacroElement
  File "/home/rtfm/.local/lib/python3.7/site-packages/branca/element.py", line 20, in <module>
    from .utilities import _camelify, _parse_size, none_max, none_min
  File "/home/rtfm/.local/lib/python3.7/site-packages/branca/utilities.py", line 25, in <module>
    import pandas as pd
  File "/home/rtfm/.local/lib/python3.7/site-packages/pandas/__init__.py", line 50, in <module>
    plot_params = pandas.plotting._style._Options(deprecated=True)
AttributeError: module 'pandas' has no attribute 'plotting'

Expected Output

Well, I expect no output, because no output means, that there's no error (at the moment). So, what I expect is, that I can correctly import the library without crashing one or more libs against each other.

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
/home/rtfm/.local/lib/python3.7/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
""")

INSTALLED VERSIONS

commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.19.12-2-MANJARO
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: de_DE.UTF-8
LOCALE: de_DE.UTF-8

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.6.2
Cython: None
numpy: 1.15.4
scipy: 1.2.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: 2.5.12
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.2
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.15
pymysql: 0.9.3
psycopg2: 2.7.6.1 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: 0.2.0
fastparquet: 0.2.1
pandas_gbq: 0.8.0
pandas_datareader: 0.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions