我在使用了几个月没有问题后,在Raspberry Pi zero上得到了这个,几个月后我再次打开它,现在我无法导入Pandas:
Python 3.7.3 (default, Oct 31 2022, 14:04:00)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 44 from C header, got 40 from PyObject
此错误与this question中的错误非常相似,但略有不同。
我试着更新我的系统:
sudo apt update
我尝试卸载并重新安装numpy和pandas:
sudo apt remove python3-numpy python3-pandas
sudo apt-get install python3-numpy python3-pandas python3-scipy python3-sklearn python3-numexpr
但这并不能解决问题
有什么想法吗
版本信息
python3-numpy/oldstable,now 1:1.16.2-1 armhf [installed]
python3-pandas-lib/oldstable,now 0.23.3+dfsg-3 armhf [installed,automatic]
python3-pandas/oldstable,now 0.23.3+dfsg-3 all [installed]
系统信息
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
1条答案
按热度按时间htrmnn0y1#
感谢@Rory Yorke在评论中指出了这个问题。
从您的错误中,导入的pandas位于
/home/pi/.local/lib/python3.7/site-packages/pandas/__init__.py
中-apt-get应该位于/usr/
中的某个位置。这看起来像一个pip --user
安装。显然,安装了两个版本的Pandas。删除pip版本解决了问题: