ModuleNotFoundError: No module named 'pyppeteer.launcher'; 'pyppeteer' is not a package
Fixes the pyppeteer shadowing failure where Python finds a pyppeteer.py file instead of the package. Use when the error says `'pyppeteer' is not a package`. Not for plain `No module named 'pyppeteer'`.
You have a file named pyppeteer.py in your working directory, so Python imports your file instead of the installed package, and your file has no launcher submodule. Rename your file to anything else (and delete __pycache__), and the real package imports normally.
The error
ModuleNotFoundError: No module named 'pyppeteer.launcher'; 'pyppeteer' is not a packageFix it
- Confirm the shadowing
python -c "import pyppeteer; print(pyppeteer.__file__)"Expected: if it prints a path in your project ending in pyppeteer.py, that file is the problem. A real install prints a site-packages __init__.py path.
- Rename your file
Rename pyppeteer.py to something like pyppeteer_script.py and delete the __pycache__ folder next to it. Then:
python -c "from pyppeteer.launcher import launch; print('ok')"Expected: prints ok.
When this applies
- the error says
'pyppeteer' is not a package - your script lives next to a file named
pyppeteer.py - the import works in every folder except your project folder
When it does NOT apply
- plain
No module named 'pyppeteer'means nothing is installed - this is the same shadowing trap as the selenium/playwright
X.pyfiles, just with pyppeteer's name
Compatibility
All pyppeteer versions. The '; 'pyppeteer' is not a package' suffix is Python telling you it found a module where a package was expected.
Why it happens
Python's import order checks the script's directory before site-packages. Naming your script pyppeteer.py makes your file the pyppeteer module. When something then asks for the pyppeteer.launcher submodule, the import system complains that your single file is not a package and therefore cannot contain submodules.
Edge cases
- Tutorials sometimes tell you to save example code as
pyppeteer.py. Do not. The name is reserved by the package. - A
pyppeteer/folder with an incomplete__init__.pyshadows the same way. Rename it too.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.