ImportError: cannot import name _uuid_generate_random

In the process of upgrading ERPNext V5 to V6 and received the following error. Any suggestions to resolve it, please?

INFO:bench.utils:setting up sudoers
Already up-to-date.
Requirement already satisfied (use --upgrade to upgrade): Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.app:pulling erpnext
    From https://github.com/frappe/erpnext
  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.app:pulling shopping_cart
    From https://github.com/frappe/shopping-cart
  • branch master -> FETCH_HEAD
    Already up-to-date.
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    Migrating site1.local
    Updating frappe : [========================================]
    Updating erpnext : [========= ]Traceback (most recent call last):
    File “/usr/lib64/python2.7/runpy.py”, line 162, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib64/python2.7/runpy.py”, line 72, in _run_code
    exec code in run_globals
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
    main()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 610, in call
    return self.main(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 590, in main
    rv = self.invoke(ctx)
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 416, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands.py”, line 215, in migrate
    frappe.model.sync.sync_all(verbose=context.verbose)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py”, line 19, in sync_all
    sync_for(app, force, verbose=verbose)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py”, line 43, in sync_for
    import_file_by_path(doc_path, force=force)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 54, in import_file_by_path
    import_doc(doc, force=force, data_import=data_import, pre_process=pre_process)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 122, in import_doc
    doc.insert()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 211, in insert
    self.run_post_save_methods()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 622, in run_post_save_methods
    self.run_method(“on_update”)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 566, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 722, in composer
    return composed(self, method, *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 705, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 560, in
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 135, in on_update
    self.run_module_method(“on_doctype_update”)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 144, in run_module_method
    module = load_doctype_module(self.name, self.module)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/init.py”, line 64, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(get_module_name(doctype, module, prefix))
    File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 598, in get_module
    return importlib.import_module(modulename)
    File “/usr/lib64/python2.7/importlib/init.py”, line 37, in import_module
    import(name)
    File “/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/newsletter/newsletter.py”, line 12, in
    import erpnext.tasks
    File “/home/frappe/frappe-bench/apps/erpnext/erpnext/tasks.py”, line 6, in
    from frappe.celery_app import celery_task, task_logger
    File “/home/frappe/frappe-bench/apps/frappe/frappe/celery_app.py”, line 5, in
    from celery import Celery
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/celery/init.py”, line 130, in
    from celery import five
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/celery/five.py”, line 149, in
    from kombu.utils.compat import OrderedDict # noqa
    File “/home/frappe/frappe-bench/env/lib/python2.7/site-packages/kombu/utils/init.py”, line 19, in
    from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random
    ImportError: cannot import name _uuid_generate_random
    Traceback (most recent call last):
    File “/usr/bin/bench”, line 9, in
    load_entry_point(‘bench==0.1’, ‘console_scripts’, ‘bench’)()
    File “/home/frappe/bench-repo/bench/cli.py”, line 60, in cli
    bench()
    File “/usr/lib/python2.7/site-packages/click/core.py”, line 610, in call
    return self.main(*args, **kwargs)
    File “/usr/lib/python2.7/site-packages/click/core.py”, line 590, in main
    rv = self.invoke(ctx)
    File “/usr/lib/python2.7/site-packages/click/core.py”, line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/lib/python2.7/site-packages/click/core.py”, line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/lib/python2.7/site-packages/click/core.py”, line 416, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/bench-repo/bench/cli.py”, line 241, in _update
    update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
    File “/home/frappe/bench-repo/bench/cli.py”, line 270, in update
    patch_sites(bench=bench_path)
    File “/home/frappe/bench-repo/bench/utils.py”, line 163, in patch_sites
    run_frappe_cmd(’–site’, ‘all’, ‘migrate’, bench=bench)
    File “/home/frappe/bench-repo/bench/utils.py”, line 496, in run_frappe_cmd
    raise CommandFailedError(args)
    bench.utils.CommandFailedError: (’–site’, ‘all’, ‘migrate’)

@fcpl go to frappe-bench folder and run ./env/bin/pip install --upgrade celery

Hi @anand

That worked like a charm. I was able to upgrade to V6.

Thank you.