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

安装Python3.10.8与Pandas后运行脚本报错ModuleNotFoundError

解决Pandas导入报错ModuleNotFoundError: No module named 'pandas._libs.pandas_parser'
  • 排查目录命名冲突
    从错误路径能看到,你的脚本my_test2.py放在了名为pandas的文件夹里,Python会优先从当前目录导入同名的pandas文件夹,而非虚拟环境中安装的Pandas包。
    解决:把my_test2.py移到pandas文件夹外(比如直接放在Documents目录下),再重新运行脚本。

  • 确认虚拟环境激活状态
    确保运行脚本前test_env虚拟环境处于激活状态(命令行前缀显示(test_env))。未激活的话先执行:

    .\test_env\Scripts\Activate.ps1
    
  • 强制重装Pandas(修复损坏文件)
    激活虚拟环境后,执行以下命令彻底清理并重装:

    pip uninstall -y pandas
    pip cache purge
    pip install pandas
    
  • 验证Python解释器路径
    确认使用的是虚拟环境内的Python,而非系统Python。运行命令查看路径:

    where python
    

    若第一个路径不是虚拟环境的Python(比如C:\Users\my_user\Documents\test_env\Scripts\python.exe),直接用完整路径运行脚本:

    C:\Users\my_user\Documents\test_env\Scripts\python.exe .\my_test2.py
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 13:21:03