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

Thonny中导入numpy遇ModuleNotFoundError的路径问题求助

Fixing "ModuleNotFoundError: No module named 'numpy'" in Thonny When numpy is Already Installed

Hey there! This is a super common hiccup when your command prompt and Thonny are using different Python environments. Let's walk through how to get this sorted out quickly:

Step 1: Check which Python interpreter Thonny is using

  • Open Thonny, then head to Tools > Options (or File > Settings if you're on an older version)
  • Switch to the Interpreter tab—here you'll see the full path to the Python executable Thonny is currently using (e.g., C:\Users\JoshPC\AppData\Local\Programs\Python\Python39\python.exe)

Step 2: Verify which Python your command prompt's pip is linked to

  • Go back to your command prompt and run these two commands:
    • where python: This lists all Python executables on your system
    • pip --version: This will show you the exact Python version and path that your pip is associated with (you should see something like pip 21.2.4 from c:\users\joshpc\appdata\local\programs\python\python36\lib\site-packages\pip (python 3.6))

Step 3: Align Thonny with the Python that has numpy installed

If the path from Thonny's interpreter doesn't match the one from pip --version:

  • Click the Browse button in Thonny's Interpreter tab
  • Navigate to the Python executable that matches your pip's path (in your case, it's C:\Users\JoshPC\AppData\Local\Programs\Python\Python36\python.exe)
  • Select it, hit OK, then restart Thonny
  • Try importing numpy again—this should work now!

Alternative: Install numpy directly through Thonny

If you'd rather skip the path checking, you can install numpy right in Thonny:

  • Go to Tools > Manage Packages
  • Type numpy in the search bar and click Search
  • Click the Install button next to numpy—Thonny will install it directly to the interpreter it's currently using, so you won't have path mismatches anymore

Why this happens

Your system might have multiple Python versions installed (even if you don't remember installing them!). The pip in your command prompt is tied to one version, but Thonny defaults to another. That's why numpy shows up as installed in the prompt but is missing in Thonny—they're looking at separate environments.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:04:13