安装 scipy 1.14.1 后,以前可行的 Python 程序现在失败了。
原始程序更复杂,所以这里有一个 MRE:
import pandas as pd
import plotly.express as px
if __name__ == "__main__":
data = {
"Date": [0, 7, 14, 21, 28],
"Value": [100, 110, 120, 115, 122]
}
df = pd.DataFrame(data)
px.scatter(df, x="Date", y="Value", trendline="ols")
这是堆栈跟踪(用户名已混淆):
Traceback (most recent call last):
File "/Users/****/Python/Aug22.py", line 12, in <module>
tl = px.scatter(
^^^^^^^^^^^
File "/Users/****/venv/lib/python3.12/site-packages/plotly/express/_chart_types.py", line 66, in scatter
return make_figure(args=locals(), constructor=go.Scatter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/****/venv/lib/python3.12/site-packages/plotly/express/_core.py", line 2267, in make_figure
patch, fit_results = make_trace_kwargs(
^^^^^^^^^^^^^^^^^^
File "/Users/****/venv/lib/python3.12/site-packages/plotly/express/_core.py", line 361, in make_trace_kwargs
y_out, hover_header, fit_results = trendline_function(
^^^^^^^^^^^^^^^^^^^
File "/Users/****/venv/lib/python3.12/site-packages/plotly/express/trendline_functions/__init__.py", line 43, in ols
import statsmodels.api as sm
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/api.py", line 136, in <module>
from .regression.recursive_ls import RecursiveLS
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/regression/recursive_ls.py", line 14, in <module>
from statsmodels.tsa.statespace.mlemodel import (
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/tsa/statespace/mlemodel.py", line 33, in <module>
from .simulation_smoother import SimulationSmoother
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/tsa/statespace/simulation_smoother.py", line 11, in <module>
from .kalman_smoother import KalmanSmoother
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/tsa/statespace/kalman_smoother.py", line 11, in <module>
from statsmodels.tsa.statespace.representation import OptionWrapper
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/tsa/statespace/representation.py", line 10, in <module>
from .tools import (
File "/Users/****/venv/lib/python3.12/site-packages/statsmodels/tsa/statespace/tools.py", line 14, in <module>
from . import (_initialization, _representation, _kalman_filter,
File "statsmodels/tsa/statespace/_initialization.pyx", line 1, in init statsmodels.tsa.statespace._initialization
ImportError: dlopen(/Users/****/venv/lib/python3.12/site-packages/statsmodels/tsa/statespace/_representation.cpython-312-darwin.so, 0x0002): symbol not found in flat namespace '_npy_cabs'
如果我恢复到 scipy 1.14.0,则不会发生此错误。
我能做些什么来让我运行 scipy 1.14.1 吗?
平台:
macOS 14.6.1
python 3.12.5
Apple M2