ERPNext Conference 2019* ERPNext.com Blog

Error after migration to Python3


#1

Hi!

I’m getting the following error after migrating to python 3:

    [2019-09-17 08:01:30 +0200] [20372] [ERROR] Error handling request /
Traceback (most recent call last):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 52, in application
    init_request(request)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 117, in init_request
    frappe.local.http_request = frappe.auth.HTTPRequest()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/auth.py", line 51, in __init__
    frappe.local.login_manager = LoginManager()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/auth.py", line 113, in __init__
    self.make_session(resume=True)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/auth.py", line 188, in make_session
    full_name=self.full_name, user_type=self.user_type)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 197, in __init__
    self.resume()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 258, in resume
    data = self.get_session_record()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 275, in get_session_record
    r = self.get_session_data()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 291, in get_session_data
    data = self.get_session_data_from_db()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 320, in get_session_data_from_db
    """, (self.sid, get_expiry_period_for_query(self.device)))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 381, in get_expiry_period_for_query
    return get_expiry_in_seconds(device=device)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 385, in get_expiry_in_seconds
    expiry = get_expiry_period(device)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/sessions.py", line 397, in get_expiry_period
    exp_sec = frappe.defaults.get_global_default(key) or default
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/defaults.py", line 105, in get_global_default
    if not_in_user_permission(key, value):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/defaults.py", line 61, in not_in_user_permission
    user_permission = get_user_permissions(user).get(frappe.unscrub(key)) or []
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/defaults.py", line 74, in get_user_permissions
    return _get_user_permissions(user)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/core/doctype/user_permission/user_permission.py", line 95, in get_user_permissions
    filters=dict(user=user)):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 1293, in get_all
    return get_list(doctype, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 1266, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 95, in execute
    result = self.build_and_run()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 109, in build_and_run
    args = self.prepare_args()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 136, in prepare_args
    self.build_conditions()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 323, in build_conditions
    self.build_filter_conditions(self.filters, self.conditions)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 344, in build_filter_conditions
    conditions.append(self.prepare_filter_condition(f))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 351, in prepare_filter_condition
    f = get_filter(self.doctype, f)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/data.py", line 898, in get_filter
    meta = frappe.get_meta(f.doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 759, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 37, in get_meta
    meta = Meta(doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 84, in __init__
    super(Meta, self).__init__("DocType", doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 104, in __init__
    self.load_from_db()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 89, in load_from_db
    super(Meta, self).load_from_db()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 155, in load_from_db
    table_fields = self.meta.get_table_fields()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/base_document.py", line 74, in meta
    self._meta = frappe.get_meta(self.doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 759, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 33, in get_meta
    meta = frappe.cache().hget("meta", doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 177, in hget
    value = pickle.loads(value)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdd in position 1: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/erpnext/frappe-bench/env/lib/python3.5/site-packages/gunicorn/workers/sync.py", line 135, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/erpnext/frappe-bench/env/lib/python3.5/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/home/erpnext/frappe-bench/env/lib/python3.5/site-packages/werkzeug/local.py", line 231, in application
    return ClosingIterator(app(environ, start_response), self.cleanup)
  File "/home/erpnext/frappe-bench/env/lib/python3.5/site-packages/werkzeug/wrappers/base_request.py", line 237, in application
    resp = f(*args[:-2] + (request,))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 81, in application
    response = handle_exception(e)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 191, in handle_exception
    http_status_code=http_status_code)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/website/render.py", line 33, in render
    raise_if_disabled(path)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/website/render.py", line 345, in raise_if_disabled
    'route': ['like', '%{0}'.format(path)]
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/database.py", line 527, in get_all
    return frappe.get_all(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 1293, in get_all
    return get_list(doctype, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 1266, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 95, in execute
    result = self.build_and_run()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 109, in build_and_run
    args = self.prepare_args()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 136, in prepare_args
    self.build_conditions()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 323, in build_conditions
    self.build_filter_conditions(self.filters, self.conditions)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 344, in build_filter_conditions
    conditions.append(self.prepare_filter_condition(f))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/db_query.py", line 351, in prepare_filter_condition
    f = get_filter(self.doctype, f)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/data.py", line 898, in get_filter
    meta = frappe.get_meta(f.doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 759, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 37, in get_meta
    meta = Meta(doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 84, in __init__
    super(Meta, self).__init__("DocType", doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 104, in __init__
    self.load_from_db()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 89, in load_from_db
    super(Meta, self).load_from_db()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 155, in load_from_db
    table_fields = self.meta.get_table_fields()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/base_document.py", line 74, in meta
    self._meta = frappe.get_meta(self.doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/__init__.py", line 759, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 33, in get_meta
    meta = frappe.cache().hget("meta", doctype)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 177, in hget
    value = pickle.loads(value)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdd in position 1: ordinal not in range(128)

Please help!


#2

try by running following commands

bench setup requirements
sudo supervisor restart all

#3

Thanks!