</>CodeWithKarani
All of Python & FastAPI
Python & FastAPI

Packaging & Environments

pip, poetry, uv, virtualenvs and ModuleNotFoundError.

6 articles

Security12 min read

Exactly-once over an unreliable pipe: HMAC, nonces, and a byte-exact contract

A per-request nonce and a per-content hash look like the same idea and are not. One says this request arrived twice, the other says this message arrived twice, and a payment pipeline needs both. The signing design behind a production SMS gateway.

Read
Python & FastAPI9 min read

Error loading ASGI app: why uvicorn cannot import your FastAPI module

Uvicorn resolves 'module:app' against sys.path, not your file's location. The real cause, the right command for flat, package, src and Docker layouts, and how to verify it.

Read
Python & FastAPI6 min read

ModuleNotFoundError: No module named 'fastapi' - the Three Unrelated Causes

One error message, three completely different causes: wrong virtualenv, package not installed, or a stale editable install left behind by switching between pip, poetry and uv.

Read
Python & FastAPI7 min read

'No module named pydantic_core._pydantic_core' in Docker or Lambda Is an Architecture Mismatch

This error is not a missing package. pydantic-core ships a compiled Rust wheel, and installing it for the wrong CPU or glibc means the files exist but cannot load.

Read
Python & FastAPI6 min read

pip 'externally-managed-environment': What PEP 668 Protects and the Right Fix

The externally-managed-environment error is PEP 668 stopping pip from corrupting your OS packages. Use a venv, not --break-system-packages, and here is exactly why --user is not reliable.

Read
Frappe/ERPNext7 min read

cannot import name 'Table' from 'frappe.query_builder': Use DocType

The frappe.query_builder rewrite around pypika dropped Table with no shim. Here is the correct import, the root cause, and version-tolerant code that survives upgrades.

Read