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

PyCharm中已安装openpyxl却提示ModuleNotFoundError问题求助

Fixing "ModuleNotFoundError: No module named 'openpyxl'" in PyCharm

Hey there, no need to stress—this is one of the most common hiccups when you're getting started with PyCharm and Python packages. Let's walk through the fixes step by step:

  • Check which Python interpreter PyCharm is using
    PyCharm often uses a dedicated virtual environment for each project, which might not have the packages you installed globally. Here's how to verify:

    1. Go to File > Settings (or PyCharm > Preferences on Mac)
    2. Navigate to Project: [Your Project Name] > Python Interpreter
    3. Look through the list of installed packages—if openpyxl isn't there, that's the root of the problem.
  • Install openpyxl directly in PyCharm's interpreter
    If it's missing from the interpreter list, you can install it right from the settings:

    1. In the Python Interpreter page, click the + icon in the top-right corner
    2. Search for openpyxl in the package search bar
    3. Select it and click Install Package—wait for the installation to finish, then try importing again.
  • Use PyCharm's Terminal to install the package
    Sometimes using the built-in Terminal is more straightforward, as it automatically uses the project's active interpreter:

    1. Open the Terminal tab at the bottom of PyCharm
    2. Run the command:
      pip install openpyxl
      
      (If you're explicitly using Python 3, you might need pip3 install openpyxl instead)
  • Double-check your global vs virtual environment setup
    If you installed openpyxl using pip outside of PyCharm, it's probably in your global Python installation. But if your PyCharm project is using a virtual environment, that global package won't be available. The fixes above will ensure the package is installed in the correct environment for your project.

Once you've done one of these steps, go ahead and try importing openpyxl again—it should work! This is just a matter of making sure PyCharm is looking in the right place for your installed packages, and it gets easier once you get familiar with how PyCharm manages interpreters.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:44:32