scipy 1.14.1 破坏 statsmodels 0.14.2

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

安装 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
python macos scipy
1个回答
0
投票

最后一行是“ImportError”,所以乍一看似乎 scipy 的构建不正确。两名 Mac 用户报告了类似的事故这里这里

为了确保这是一个足够相似的问题:

  • 检查其他Python程序是否失败(在第一个链接中,'import numpy'导致了同样的错误)
  • 检查最新 scipy 版本的构建日志,查找链接警告,例如: ld:警告:忽略文件 build/temp.macosx-11-arm64-3.8/libnpymath.a,为 macOS-arm64 构建,但尝试链接为未知不支持的文件格式构建的文件)

两者都解决了他们的问题。他们的解决方案:

  • 第一个人修改了他的路径以包含一些与苹果包含的版本冲突的GNU binutils(特别是ranlib);
  • 第二个人使用brew安装依赖项(protobuf)并通过使用conda解决了他的问题。
© www.soinside.com 2019 - 2024. All rights reserved.