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

导入plotly.express触发ImportError:需安装pandas,如何解决?

Fix for ImportError: Plotly express requires pandas to be installed

Hey there! I’ve run into this exact issue before, so let me walk you through how to fix it quickly.

Why this happens

While the core plotly library doesn’t depend on pandas, Plotly Express (px) relies heavily on pandas for handling data structures (like DataFrames) and loading its built-in sample datasets. It’s a bit frustrating that the installation docs don’t call this out explicitly, but it’s a critical dependency for most of px’s functionality.

Step-by-step solution

  • First, install pandas using your package manager:
    • If you’re using pip:
      pip install pandas
      
    • If you’re working in a Conda environment:
      conda install pandas
      
  • Once installed, verify the fix by running these lines in your Python environment:
    import pandas
    import plotly.express as px
    
    If no errors pop up, you’re all set to use px’s features!

Quick heads-up

Make sure you’re installing pandas in the same Python environment where you have plotly installed. If you use virtual environments, double-check that you’ve activated the correct one before running the install command—this is a super common gotcha that can make it seem like the install didn’t work even if it did.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 00:07:53