Fix "ModuleNotFoundError" & "Pip is not recognized" in Python (Windows Guide)
You downloaded a cool Python script (maybe my WhatsApp Automation Bot or Auto-Print Tool), you are ready to code, but when you type the install command, Windows gives you the cold shoulder:
'pip' is not recognized as an internal or external command, operable program or batch file.
Or worse, you successfully install a library, run the script, and get ModuleNotFoundError: No module named 'selenium'. Why does this happen?
The root cause is usually a missing checkbox during installation. When you installed Python, you likely forgot to check "Add Python to PATH". Here is how to fix your environment manually without reinstalling.
Fix 1: Add Python to PATH (The "Pip" Fix)
We need to tell Windows exactly where the pip.exe file is hiding.
- Press
Win + Sand search for "Edit the system environment variables". - Click the Environment Variables button at the bottom right.
- In the bottom section "System variables", find the variable named Path and double-click it.
- Click New and add these two paths (You might need to browse your C: drive to find the exact version folder):
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\(For Python.exe)C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts\(For Pip.exe)
- Click OK on all windows.
- Crucial Step: Close your Command Prompt and open a new one. Windows only loads the new Path on restart.
Type pip --version. If you see a version number, congratulations!
Fix 2: The "Virtual Environment" Trap (Module Not Found)
If pip works but the script still says "Module Not Found", you are likely dealing with environment isolation.
Python best practice is to create a "Virtual Environment" (venv) for each project. This keeps your dependencies clean.
# 1. Open CMD inside your project folder
# 2. Create the environment
python -m venv venv
# 3. Activate it (You will see (venv) appear on the left)
.\venv\Scripts\activate
# 4. NOW install the library inside this bubble
pip install selenium
Always check if you see (venv) at the start of your command line before running your scripts!
Author: Marg | Daily Innovate Tech
.png)
Post a Comment for "Fix "ModuleNotFoundError" & "Pip is not recognized" in Python (Windows Guide)"