You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级SciPy至1.13.0后出现scipy.special._cdflib缺失错误的解决问询

问题:SciPy升级至1.13后出现ModuleNotFoundError: No module named 'scipy.special._cdflib'

环境信息:Windows Server 2019、Python 3.12.2、SciPy 1.13.0

将SciPy从1.12版本升级至1.13版本后,运行PyInstaller打包的程序时出现ModuleNotFoundError: No module named 'scipy.special._cdflib'错误,使用1.12.0版本时无此问题。

报错堆栈:

Traceback (most recent call last): 
  File "src\predict.py", line 14, in <module> 
    from src.utils.calc_utils import *
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "src\utils\calc_utils.py", line 1, in <module>
    from scipy.interpolate import interp1d
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "scipy\interpolate\__init__.py", line 167, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "scipy\interpolate\_interpolate.py", line 10, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
  File "scipy\special\__init__.py", line 777, in <module>
  File "scipy\\special\\_ufuncs.pyx", line 1, in init scipy.special._ufuncs
ModuleNotFoundError: No module named 'scipy.special._cdflib'

原因分析

  • SciPy 1.13.0重构了scipy.special模块的内部依赖结构,_cdflib成为该模块的隐式依赖项,但PyInstaller的默认钩子未同步更新,无法自动识别并打包这个新增模块。
  • 本地开发环境中该模块存在于SciPy安装目录,但PyInstaller打包时遗漏了它,导致运行打包后的程序时触发模块缺失错误。

解决方法

  • 手动指定隐藏依赖打包:在PyInstaller命令中添加--hidden-import参数强制包含该模块,示例命令:
    pyinstaller --hidden-import scipy.special._cdflib src/predict.py
    
  • 更新PyInstaller到最新版本:新版本PyInstaller通常会适配主流库的版本更新,执行以下命令升级:
    pip install --upgrade pyinstaller
    
  • 回退SciPy版本:如果不需要SciPy 1.13.0的新特性,可临时回退到无问题的1.12.0版本:
    pip install scipy==1.12.0
    

内容的提问来源于stack exchange,提问作者BoilingNine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 15:07:25