frappe / non_profit

Non Profit module for Frappe/ERPNext
GNU General Public License v3.0
35 stars 55 forks source link

Install failed - No module named payments #19

Open nikkilocke opened 1 year ago

nikkilocke commented 1 year ago

I'm trying to install non_profit to an ERPNext installation running in docker.

The install fails as follows:

App erpnext already installed

Installing non_profit...
Updating DocTypes for non_profit    : [                    ] 4%An error occurred while installing non_profit: Module import failed for Non Profit Settings, the DocType you're trying to open might be deleted.<br> Error: No module named 'payments'
Traceback (most recent call last):
  File "apps/frappe/frappe/modules/utils.py", line 240, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "apps/frappe/frappe/__init__.py", line 1327, in get_module
    return importlib.import_module(modulename)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "apps/non_profit/non_profit/non_profit/doctype/non_profit_settings/non_profit_settings.py", line 9, in <module>
    from payments.utils import get_payment_gateway_controller
ModuleNotFoundError: No module named 'payments'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 413, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 294, in install_app
    sync_for(name, force=force, reset_permissions=True)
  File "apps/frappe/frappe/model/sync.py", line 80, in sync_for
    import_file_by_path(
  File "apps/frappe/frappe/modules/import_file.py", line 145, in import_file_by_path
    import_doc(
  File "apps/frappe/frappe/modules/import_file.py", line 242, in import_doc
    doc.insert()
  File "apps/frappe/frappe/model/document.py", line 285, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1077, in run_post_save_methods
    self.run_method("on_update")
  File "apps/frappe/frappe/model/document.py", line 909, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1259, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1241, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 906, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 408, in on_update
    self.run_module_method("on_doctype_update")
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 493, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "apps/frappe/frappe/modules/utils.py", line 244, in load_doctype_module
    raise ImportError(msg) from e
ImportError: Module import failed for Non Profit Settings, the DocType you're trying to open might be deleted.<br> Error: No module named 'payments'
nikkilocke commented 1 year ago

I Googled the error, and found that payments was a separate app I had to install (maybe you could mention that in the README install instructions?).

So I got it, and installed it. Then tried to install non_profit again, and got this:

App erpnext already installed

Installing non_profit...
An error occurred while installing non_profit: ('Module Def', 'Non Profit', IntegrityError(1062, "Duplicate entry 'Non Profit' for key 'PRIMARY'"))
Traceback (most recent call last):
  File "apps/frappe/frappe/model/base_document.py", line 496, in db_insert
    frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 218, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, "Duplicate entry 'Non Profit' for key 'PRIMARY'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 413, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 292, in install_app
    add_module_defs(name, ignore_if_duplicate=force)
  File "apps/frappe/frappe/installer.py", line 623, in add_module_defs
    d.insert(ignore_permissions=True, ignore_if_duplicate=ignore_if_duplicate)
  File "apps/frappe/frappe/model/document.py", line 270, in insert
    self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
  File "apps/frappe/frappe/model/base_document.py", line 523, in db_insert
    raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Module Def', 'Non Profit', IntegrityError(1062, "Duplicate entry 'Non Profit' for key 'PRIMARY'"))
nikkilocke commented 1 year ago

Went into the database and executed this:

delete from `tabModule Def` WHERE NAME LIKE '%ofit%';

Seems to be installed now. Be good to a. update the README b. have a SQL transaction round the install process, so spurious records don't get left on failure.