调试时,在从Scipy导入之前使用pandas会导致导入时出现类型错误。

4
在Mac上使用PyCharm 2021.3(社区版)进行调试时,代码如下:
import pandas as pd
x = pd.DataFrame()
from scipy.stats import poisson

生成异常:

...
  File "/.../venv/lib/python3.10/site-packages/numpy/core/getlimits.py", line 518, in __init__
    self.dtype = numeric.dtype(type(int_type))
TypeError: 'NoneType' object is not callable

None 变量是 numeric.dtype

Python 3.10.0
依赖项: pip install numpy==1.21.2 pandas==1.3.5 scipy==1.7.3


还与https://stackoverflow.com/questions/70588672/something-wrong-about-scipy-and-numpy-when-i-import-scipy-stats-linregress有关。 - e.tadeu
1个回答

3
这是一个已知的(但未解决的)问题;请参见github上的pandas issue 41935。那里的一些评论表明它可能是Python或Cython bug的问题。

2
有什么解决方法吗?我经常遇到这个问题。 - Rugnir

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接