Skip to content
Docs

ModuleNotFoundError: No module named

We install only the packages your code lists. Add the missing one to requirements.txt, or to the file your tool uses, and push again.

Updated 17 Oct 20262 min read

The fix on Tanzahost: add the missing package to the file we install from, commit it, and push. The next build installs it. With requirements.txt, run this in your project's own virtual environment on your computer, so the file lists only this project's packages:

Terminal
pip install requests
pip freeze > requirements.txt
git add requirements.txt
git commit -m "Add requests"
git push

Replace requests with the module from the error. A module's name isn't always its package's: No module named 'yaml' is the package PyYAML, cv2 is opencv-python, PIL is Pillow, and dotenv is python-dotenv.

Why it happens

Your app works on your computer because the package is installed there, often for every project at once. On Tanzahost each build starts clean, in its own sandbox, and installs only what your code lists, into the app's own environment. We look for these files, in this order, and install from the first we find:

Your code hasWe run
uv.lockuv sync --frozen --no-dev
poetry.lockpoetry install --only main --no-root
Pipfilepipenv's packages, through pip
requirements.txtpip install -r requirements.txt
pyproject.toml or setup.pypip install .

So a package missing from that file is missing here. Two more cases catch people out:

  • Development packages. uv's --no-dev and Poetry's --only main leave out what you marked for development. A package your app imports while it runs belongs with the main ones.

  • Two files. With both poetry.lock and requirements.txt, we use Poetry's, and the other file is ignored.

The build log shows which one we used, as its first step: "Running pip install", "Running uv sync", "Running poetry install" or "Running pipenv install".

How to check

  1. Open the build's log and find the install step. The packages it installed are listed there.

  2. Look for the module in the file that step used. If it's not there, add it.

  3. If your app lives in a folder of a larger repository, the file must be in that Folder (under Build and run), not only at the top.

  4. In the app's terminal, list what's installed: pip list.