Python 3.7.1导入auto_arima报错:无法从scipy.misc导入factorial
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 scipyFor 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 oldscipy.misc.factorialimport. Version 1.5.3 is confirmed to play nice with scipy 1.3.0. Install it with:pip install pmdarima==1.5.3Manual 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'sLib/site-packages/pmdarimadirectory, find the file with the linefrom scipy.misc import factorial, and replace it with:from scipy.special import factorialJust note this change will get overwritten if you update pmdarima later, so only use this for urgent testing.
内容的提问来源于stack exchange,提问作者Crossfit_Jesus

