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

Windows10 64位Anaconda Spyder2.7+Psychopy中openpyxl依赖报错求助

Fixing "ImportError: openpyxl is required for loading excel format files" in PsychoPy (Anaconda Spyder 2.7, Windows 10 64-bit)

Hey there, let’s work through this frustrating openpyxl import issue you’re hitting with PsychoPy on your Python 2.7 setup. I’ve dealt with similar dependency mismatches before, so here are actionable steps to resolve it:

1. Install a Python 2.7-compatible version of openpyxl

Openpyxl dropped support for Python 2.7 starting with version 3.0. If you installed the latest version, it won’t work with your Spyder 2.7 environment. Here’s how to fix this:

  • Open Anaconda Prompt
  • If you’re using a dedicated environment for PsychoPy, activate it first:
    conda activate your_psychopy_env
    
  • Install the last openpyxl version that supports Python 2.7:
    pip install openpyxl==2.6.4
    
    (If pip doesn’t work, try conda install openpyxl==2.6.4 instead)

2. Confirm Spyder is using the correct Anaconda environment

Sometimes Spyder defaults to a different Python interpreter than the one where you installed openpyxl/Psychopy:

  • In Spyder, go to Tools > Preferences > Python interpreter
  • Make sure the selected interpreter path points to the Python.exe in your PsychoPy/Python 2.7 environment (e.g., C:\Users\YourUsername\anaconda3\envs\py27\python.exe)
  • Restart Spyder to apply the change

3. Update all openpyxl imports in PsychoPy’s data.py

You modified one import line, but there might be other outdated references in the file:

  • Locate the data.py file in your PsychoPy installation directory (usually under Lib\site-packages\psychopy\data in your Anaconda environment)
  • Search for all instances of from openpyxl.cell import get_column_letter and replace them with from openpyxl.utils import get_column_letter
  • Save the file and restart Spyder

4. Verify openpyxl installation in Spyder

To double-check everything is set up correctly, run these lines in Spyder’s IPython console:

import openpyxl
print("Openpyxl version:", openpyxl.__version__)
print("Openpyxl install path:", openpyxl.__file__)
  • If you get an import error here, your Spyder environment isn’t pointing to the right installation
  • If the version is 2.6.x, you’re good to go; if it’s 3.x, you need to downgrade as step 1 outlines

If you can share the exact code snippet that’s triggering the error and the full traceback, we can narrow down any remaining issues, but these steps should resolve the core problem.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:37:31