frappe / insights

Open Source Business Intelligence Tool
https://frappe.io/insights
GNU Affero General Public License v3.0
454 stars 222 forks source link

Installation fails with "No module named 'urllib3.contrib.appengine'" in Ubuntu 24.04 #275

Open zefanja opened 4 months ago

zefanja commented 4 months ago

When I want to install insights on my site I get this error (on Ubuntu 24.04):

Installing insights...
Updating DocTypes for insights      : [=========================               ] 62%An error occurred while installing insights: Module import failed for Insights Alert, the DocType you're trying to open might be deleted.<br> Error: No module named 'urllib3.contrib.appengine'
Traceback with variables (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 445, in install_app
    _install_app(app, verbose=context.verbose, force=force)
      context = {'sites': ['erp15.example.com'], 'force': False, 'verbose': False, 'profile': False}
      apps = ('insights',)
      force = True
      _install_app = <function install_app at 0x7f451d7b7380>
      filelock = <function filelock at 0x7f451d7b4a40>
      exit_code = 0
      site = 'erp15.example.com'
      app = 'insights'
      err = ImportError("Module import failed for Insights Alert, the DocType you're trying to open might be deleted.<br> Error: No module named 'urllib3.contrib.appengine'")
  File "apps/frappe/frappe/installer.py", line 301, in install_app
    sync_for(name, force=force, reset_permissions=True)
      name = 'insights'
      verbose = False
      set_as_patched = True
      force = True
      sync_jobs = <function sync_jobs at 0x7f451bd70400>
      sync_for = <function sync_for at 0x7f451bd711c0>
      sync_customizations = <function sync_customizations at 0x7f451d779440>
      sync_fixtures = <function sync_fixtures at 0x7f451bd714e0>
      app_hooks = {'app_color': ['grey'], 'app_description': ['Powerful Reporting Tool for Frappe Apps'], 'app_email': ['hello@frappe.io'], 'app_icon': ['octicon octicon-file-directory'], 'app_license': ['GNU GPLv3'], 'app_name': ['insights'], 'app_publisher': ['Frappe Technologies Pvt. Ltd.'], 'app_title': ['Frappe Insights'], 'app_version': ['1.1.3'], 'before_tests': ['insights.tests.utils.before_tests'], 'fixtures': [{'dt': 'Insights Data Source', 'filters': {'name': ('in', ['Site DB', 'Query Store'])}}], 'has_permission': {'Insights Data Source': ['insights.overrides.has_permission'], 'Insights Table': ['insights.overrides.has_permission'], 'Insights Query': ['insights.overrides.has_permission'], 'Insights Dashboard': ['insights.overrides.has_permission']}, 'scheduler_events': {'all': ['insights.insights.doctype.insights_alert.insights_alert.send_alerts']}, 'setup_wizard_requires': ['assets/insights/js/setup_wizard.js'], 'setup_wizard_stages': ['insights.setup.setup_wizard.get_setup_stages'], 'websi...
      installed_apps = ['frappe', 'erpnext', 'cdsc_sis', 'sebs', 'payments', 'hrms']
  File "apps/frappe/frappe/model/sync.py", line 111, in sync_for
    import_file_by_path(
      app_name = 'insights'
      force = True
      reset_permissions = True
      files = ['apps/insights/insights/insights/doctype/insights_table/insights_table.json', 'apps/insights/insights/insights/doctype/insights_data_source/insights_data_source.json', 'apps/insights/insights/insights/doctype/insights_resource_permission/insights_resource_permission.json', 'apps/insights/insights/insights/doctype/insights_query_table/insights_query_table.json', 'apps/insights/insights/insights/doctype/insights_query_transform/insights_query_transform.json', 'apps/insights/insights/insights/doctype/insights_settings/insights_settings.json', 'apps/insights/insights/insights/doctype/insights_table_link/insights_table_link.json', 'apps/insights/insights/insights/doctype/insights_notebook_page/insights_notebook_page.json', 'apps/insights/insi...
      module_name = 'insights'
      folder = 'apps/insights/insights/insights'
      l = 24
      i = 15
      doc_path = 'apps/insights/insights/insights/doctype/insights_alert/insights_alert.json'
  File "apps/frappe/frappe/modules/import_file.py", line 146, in import_file_by_path
    import_doc(
      path = 'apps/insights/insights/insights/doctype/insights_alert/insights_alert.json'
      force = True
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = True
      docs = [{'actions': [], 'allow_rename': 1, 'creation': '2023-03-30 16:39:47.081742', 'default_view': 'List', 'doctype': 'DocType', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'default': '0', 'fieldname': 'disabled', 'fieldtype': 'Check', 'label': 'Disabled', 'doctype': 'DocField'}, {'fieldname': 'section_break_cmx9', 'fieldtype': 'Section Break', 'doctype': 'DocField'}, {'fieldname': 'title', 'fieldtype': 'Data', 'label': 'Title', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Email', 'fieldname': 'channel', 'fieldtype': 'Select', 'label': 'Channel', 'options': 'Email\nTelegram', 'doctype': 'DocField'}, {'fieldname': 'query', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Query', 'options': 'Insights Query', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Hourly', 'fieldname': 'frequency', 'fieldtype': 'Select', 'label': 'Frequency', 'options': 'Hourly\nDaily\nWeekly\nMonthly\nCron', 'doctype': 'DocField'}, {'depends_on': 'eval: doc.frequency == "Cron"', 'fieldname': 'cron_format'...
      calculated_hash = 'e85bf92c0c49e2d62ea075b3e8e871e9'
      doc = {'actions': [], 'allow_rename': 1, 'creation': '2023-03-30 16:39:47.081742', 'default_view': 'List', 'doctype': 'DocType', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'default': '0', 'fieldname': 'disabled', 'fieldtype': 'Check', 'label': 'Disabled', 'doctype': 'DocField'}, {'fieldname': 'section_break_cmx9', 'fieldtype': 'Section Break', 'doctype': 'DocField'}, {'fieldname': 'title', 'fieldtype': 'Data', 'label': 'Title', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Email', 'fieldname': 'channel', 'fieldtype': 'Select', 'label': 'Channel', 'options': 'Email\nTelegram', 'doctype': 'DocField'}, {'fieldname': 'query', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Query', 'options': 'Insights Query', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Hourly', 'fieldname': 'frequency', 'fieldtype': 'Select', 'label': 'Frequency', 'options': 'Hourly\nDaily\nWeekly\nMonthly\nCron', 'doctype': 'DocField'}, {'depends_on': 'eval: doc.frequency == "Cron"', 'fieldname': 'cron_format',...
      db_modified_timestamp = datetime.datetime(2024, 7, 9, 10, 31, 38, 722866)
      is_db_timestamp_latest = True
  File "apps/frappe/frappe/modules/import_file.py", line 239, in import_doc
    doc.insert()
      docdict = {'actions': [], 'allow_rename': 1, 'creation': '2023-03-30 16:39:47.081742', 'default_view': 'List', 'doctype': 'DocType', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'default': '0', 'fieldname': 'disabled', 'fieldtype': 'Check', 'label': 'Disabled', 'doctype': 'DocField'}, {'fieldname': 'section_break_cmx9', 'fieldtype': 'Section Break', 'doctype': 'DocField'}, {'fieldname': 'title', 'fieldtype': 'Data', 'label': 'Title', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Email', 'fieldname': 'channel', 'fieldtype': 'Select', 'label': 'Channel', 'options': 'Email\nTelegram', 'doctype': 'DocField'}, {'fieldname': 'query', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Query', 'options': 'Insights Query', 'reqd': 1, 'doctype': 'DocField'}, {'default': 'Hourly', 'fieldname': 'frequency', 'fieldtype': 'Select', 'label': 'Frequency', 'options': 'Hourly\nDaily\nWeekly\nMonthly\nCron', 'doctype': 'DocField'}, {'depends_on': 'eval: doc.frequency == "Cron"', 'fieldname': 'cron_format',...
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = True
      path = 'apps/insights/insights/insights/doctype/insights_alert/insights_alert.json'
      controller = <class 'frappe.core.doctype.doctype.doctype.DocType'>
      doc = <DocType: Insights Alert>
  File "apps/frappe/frappe/model/document.py", line 315, in insert
    self.run_post_save_methods()
      self = <DocType: Insights Alert>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
      d = <DocPerm: tlt47bq8lo parent=Insights Alert>
  File "apps/frappe/frappe/model/document.py", line 1128, in run_post_save_methods
    self.run_method("on_update")
      self = <DocType: Insights Alert>
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <DocType: Insights Alert>
      method = 'on_update'
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x7f44f904ba60>
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
      self = <DocType: Insights Alert>
      args = ()
      kwargs = {}
      hooks = [<function build_domain_restriced_doctype_cache at 0x7f451d778400>, <function clear_doctype_notifications at 0x7f44fb703420>, <function process_workflow_actions at 0x7f44fb71b060>, <function attach_files_to_document at 0x7f451c47b600>, <function apply at 0x7f44fb52dda0>, <function update_due_date at 0x7f44fb52de40>, <function apply_permissions_for_non_standard_user_type at 0x7f44fb52f6a0>]
      method = 'on_update'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ['frappe.workflow.doctype.workflow_action.workflow_action.process_w...
      handler = 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x7f44fb90f920>
      compose = <function Document.hook.<locals>.compose at 0x7f44fb90f9c0>
      f = <function Document.run_method.<locals>.fn at 0x7f44f904ba60>
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      self = <DocType: Insights Alert>
      method = 'on_update'
      args = ()
      kwargs = {}
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x7f44f904b920>
      fn = <function Document.run_method.<locals>.fn at 0x7f44f904ba60>
      hooks = (<function build_domain_restriced_doctype_cache at 0x7f451d778400>, <function clear_doctype_notifications at 0x7f44fb703420>, <function process_workflow_actions at 0x7f44fb71b060>, <function attach_files_to_document at 0x7f451c47b600>, <function apply at 0x7f44fb52dda0>, <function update_due_date at 0x7f44fb52de40>, <function apply_permissions_for_non_standard_user_type at 0x7f44fb52f6a0>)
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
      self = <DocType: Insights Alert>
      args = ()
      kwargs = {}
      method_object = <bound method DocType.on_update of <DocType: Insights Alert>>
      method = 'on_update'
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 531, in on_update
    self.run_module_method("on_doctype_update")
      self = <DocType: Insights Alert>
      allow_doctype_export = False
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 629, in run_module_method
    module = load_doctype_module(self.name, self.module)
      self = <DocType: Insights Alert>
      method = 'on_doctype_update'
      load_doctype_module = <function load_doctype_module at 0x7f451d779a80>
  File "apps/frappe/frappe/modules/utils.py", line 254, in load_doctype_module
    raise ImportError(msg) from e
      doctype = 'Insights Alert'
      module = 'Insights'
      prefix = ''
      suffix = ''
      app = 'insights'
      key = ********
      module_name = 'insights.insights.doctype.insights_alert.insights_alert'
      msg = "Module import failed for Insights Alert, the DocType you're trying to open might be deleted.<br> Error: No module named 'urllib3.contrib.appengine'"
builtins.ImportError: Module import failed for Insights Alert, the DocType you're trying to open might be deleted.<br> Error: No module named 'urllib3.contrib.appengine'

Version

$ bench version
erpnext 15.29.2
frappe 15.33.3
insights 1.1.3

$ python3 --version
Python 3.12.3

Might be related to this? → https://stackoverflow.com/questions/78017690/python-telegram-bot-v13-11-incompatible-with-requests-and-urllib3-libraries-usin

Abhishek-Chougule commented 4 weeks ago

source env/bin/activate

pip install urllib3==1.26.15

this will work.

Abhishek-Chougule commented 4 weeks ago

@rmehta @nabinhait @shantanoo please close as solved:

Installation fails with "No module named 'urllib3.contrib.appengine'" in Ubuntu 24.04 #275 https://github.com/frappe/insights/issues/330