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

Python 3.7.1导入auto_arima报错:无法从scipy.misc导入factorial

Fix "cannot import name 'factorial' from 'scipy.misc'" when importing auto_arima

Hey there, let's sort out this error you're hitting. The core issue here is a version mismatch between your scipy (1.3.0) and the pmdarima package you're using.

Starting around scipy 1.0+, the factorial function was moved from scipy.misc to scipy.special, and by scipy 1.3.0, the old scipy.misc.factorial entry was likely removed entirely. If your pmdarima version still expects the old import path, reinstalling scipy won't fix the problem—they're just speaking different import "languages" right now.

Here are a few reliable fixes to try:

  • Upgrade your scipy version
    This is the cleanest long-term fix, and your Python 3.7.1 supports it. Scipy 1.3.0 is pretty outdated; upgrading to a compatible newer version will align with pmdarima's import expectations. Run this command in your terminal:

    pip install --upgrade scipy
    

    For Python 3.7.1, you can safely upgrade up to scipy 1.7.3 (the last release fully compatible with Python 3.7).

  • Downgrade pmdarima to a version that works with scipy 1.3.0
    If you can't upgrade scipy for some reason, grab an older pmdarima release that still uses the old scipy.misc.factorial import. Version 1.5.3 is confirmed to play nice with scipy 1.3.0. Install it with:

    pip install pmdarima==1.5.3
    
  • Manual patch (quick fix only, not recommended long-term)
    As a last resort, you can edit the pmdarima source file causing the error. Navigate to your Python environment's Lib/site-packages/pmdarima directory, find the file with the line from scipy.misc import factorial, and replace it with:

    from scipy.special import factorial
    

    Just note this change will get overwritten if you update pmdarima later, so only use this for urgent testing.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 07:30:59