ProjectStack
python

ImportError: No module named

Python couldn't find the module you're trying to import. The package either isn't installed in the current environment, or there's a typo in the module name.

Common causes

  • The package isn't installed — you need to install it with pip
  • You're running the script with a different Python/pip than the one where the package is installed
  • A virtual environment is active but the package is installed in the global environment (or vice versa)
  • Typo in the import name — package install names and import names sometimes differ (e.g. pip install Pillow but import PIL)

How to fix it

  1. Install the missing package: pip install <package-name>
  2. If using a virtual environment, activate it first: source venv/bin/activate (Mac/Linux) or venv\Scripts\activate (Windows)
  3. Verify you're using the correct pip: python -m pip install <package> (uses the same Python as your script)
  4. Check the import name — some packages use different names for install vs import

Example

Traceback (most recent call last): File "app.py", line 1, in <module> import requests ImportError: No module named 'requests'

Running a script that imports requests before running pip install requests

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.