pandas import as pd 失败,并显示“UnicodeDecodeError:'utf-8'编解码器无法解码位置 14 中的字节 0xb0:无效的起始字节”

问题描述 投票:0回答:1

错误发生在 Raspberry Pi 上的 import 语句 (Linux rp3b 5.10.17-v7+ #1414 SMP 4 月 30 日星期五 13:18:35 BST 2021 armv7l GNU/Linux )在做事之前。这是怎么回事?

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import io
import subprocess
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates
import pandas as pd
import datetime

运行 python 脚本给出:

Traceback (most recent call last):
  File "./plotGasPerMonth.py", line 9, in <module>
    import pandas as pd
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import (
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/compat/__init__.py", line 15, in <module>
    from pandas.compat.numpy import (
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
    from pandas.util.version import Version
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/util/__init__.py", line 1, in <module>
    from pandas.util._decorators import (  # noqa
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/util/_decorators.py", line 14, in <module>
    from pandas._libs.properties import cache_readonly  # noqa
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/_libs/__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
  File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
  File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
  File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
  File "/home/pi/.local/lib/python3.7/site-packages/pandas/_libs/tslibs/__init__.py", line 31, in <module>
    from pandas._libs.tslibs.conversion import (
  File "pandas/_libs/tslibs/conversion.pyx", line 63, in init pandas._libs.tslibs.conversion
  File "pandas/_libs/tslibs/parsing.pyx", line 1, in init pandas._libs.tslibs.parsing
  File "pandas/_libs/tslibs/offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
  File "pandas/_libs/tslibs/timedeltas.pyx", line 61, in init pandas._libs.tslibs.timedeltas
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 14: invalid start byte

pandas 已安装

apt install python3-pandas

pandas raspberry-pi python-3.7
1个回答
0
投票

按照@Mark,我现在做了

python3 -m pip uninstall pandas
,然后是
python3 -m pip install pandas
。这解决了问题。谢谢

© www.soinside.com 2019 - 2024. All rights reserved.