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

在Windows命令提示符安装requests后仍遇ModuleNotFoundError问题求助

Fixing "ModuleNotFoundError: No module named 'requests'" After Installation

Hey there! Let's break down why you're hitting this error even after installing the requests library, and how to fix it step by step.

First, let's spot an obvious issue in your error trace:

File "C:\Users\mukta\OneDrive\Desktop\MYweatherApp.py", line 2, in
Import import requests

You've got a typo in your import statement—it should be only one import, like this:

import requests

That's a syntax mistake that might be adding to the confusion, so fix that first!

Now, the core problem here is almost always a Python environment mismatch. Here's how to resolve it:

  • Verify your Python and pip versions match
    Windows often has multiple Python installations (e.g., system Python, a version from the Microsoft Store, or Conda environments). When you run pip install requests, it might install the library for a different Python version than the one you're using to run your script.

    • Check which Python you're running:
      python --version
      
      Or if you use the official Python launcher:
      py --version
      
    • Check which pip you're using:
      pip --version
      

    If the versions don't line up, install requests using the Python module directly to ensure it goes to the right environment:

    python -m pip install requests
    

    Or specify the version explicitly if needed:

    py -3.11 -m pip install requests
    
  • Run your script with the correct Python interpreter
    Instead of just typing python MYweatherApp.py, use the same interpreter you installed requests for. For example:

    py -3.11 C:\Users\mukta\OneDrive\Desktop\MYweatherApp.py
    
  • Check for virtual environments
    If you're using a virtual environment for your project, make sure you've activated it before installing requests and running your script. To activate a venv:

    C:\path\to\your\venv\Scripts\activate
    

    Once activated, install requests again and run your script within this activated environment.

These steps should resolve the module not found error for most Windows users facing this issue.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 19:32:46