Skip to content

ModuleNotFoundError: No module named 'frappe' #43

@Tanoh-Hermann

Description

@Tanoh-Hermann

Reasons:

  • The app whitelabel tries to import frappe inside whitelabel/init.py
  • During pip installation, frappe is not yet available, so it crashes
  • This stops ALL apps from installing
  • Migration fails
  • Your site cannot load

Solution: Fully Safe init.py

We must wrap all frappe usage in a safe try/except. Here is a suggested content for the file: apps/whitelabel/whitelabel/init.py :

`# -- coding: utf-8 --
from future import unicode_literals

version = "0.0.1"

Safe fallback (used during pip install)

logo = "/assets/whitelabel/images/whitelabel_logo.jpg"

Try to import frappe ONLY at runtime (NOT during pip install)

try:
import frappe

if frappe.conf and frappe.conf.get("app_logo_url"):
    __logo__ = frappe.conf.get("app_logo_url") or __logo__

except Exception:
# During pip install, or if frappe is unavailable
pass`

Hope that help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions