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

安装streamlit等依赖时遇ModuleNotFoundError的解决方法

安装streamlit、fbprophet等依赖失败的解决办法

问题背景

要安装依赖:streamlit、fbprophet、yfinance、plotly,执行命令:

pip install streamlit fbprophet yfinance plotly

终端出现如下错误:

Collecting streamlit
  Using cached streamlit-1.14.0-py2.py3-none-any.whl (9.2 MB)
Collecting fbprophet
  Using cached fbprophet-0.7.1.tar.gz (64 kB)
  Preparing metadata (setup.py) ... done
Collecting yfinance
  Using cached yfinance-0.1.85-py2.py3-none-any.whl (29 kB)
Collecting plotly
  Using cached plotly-5.11.0-py2.py3-none-any.whl (15.3 MB)
# 省略中间依赖收集内容
Collecting pystan>=2.14
  Using cached pystan-3.5.0-py3-none-any.whl (13 kB)
  Using cached pystan-3.4.0-py3-none-any.whl (13 kB)
  Using cached pystan-3.3.0-py3-none-any.whl (13 kB)
  Using cached pystan-3.1.1-py3-none-any.whl (13 kB)  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\Admin\AppData\Local\Temp\pip-install-cpz50fug\pystan_29b2e0ee589444e48d57493b846dbeee\setup.py", line 122, in <module>
          from Cython.Build.Inline import _get_build_extension
      ModuleNotFoundError: No module named 'Cython'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

核心问题

  1. 缺少Cython依赖,pystan编译过程必须依赖它;
  2. fbprophet 0.7.1仅兼容pystan 2.x版本,但pip默认拉取了不兼容的pystan 3.x版本。

解决步骤

方法一:使用pip安装(通用场景)

  1. 先单独安装Cython
pip install cython
  1. 安装与fbprophet兼容的pystan版本
pip install pystan==2.19.1.1
  1. 再安装所有目标依赖
pip install streamlit yfinance plotly fbprophet

方法二:Anaconda环境推荐方案(更稳定)

Anaconda能自动处理大部分编译依赖问题,优先使用conda命令:

  1. 激活你的目标conda环境
conda activate your_env_name
  1. 安装Cython和兼容版pystan
conda install -c conda-forge cython pystan=2.19.1.1
  1. 一次性安装所有目标依赖
conda install -c conda-forge streamlit fbprophet yfinance plotly

额外注意事项

  • 如果仍有其他错误,先更新pip到最新版本:pip install --upgrade pip
  • 确保你的Python版本在3.7-3.9之间(fbprophet 0.7.1对Python 3.10+支持有限)

内容的提问来源于stack exchange,提问作者Mr.Horror

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 13:25:16