ParsimonyGit / shipstation_integration

Other
14 stars 24 forks source link

ImportError: cannot import name '_Union' from 'typing' (/home/frappe/.pyenv/versions/3.9.9/lib/python3.9/typing.py) #51

Closed batonac closed 2 years ago

batonac commented 2 years ago

Runing Python 3.9 on Debian Bullseye and seeing this error after installing all the dependencies and trying to run bench install-app shipstation_integration:

Installing shipstation_integration...
An error occurred while installing shipstation_integration: Module import failed for Shipstation Settings (shipstation_integration.shipstation_integration.doctype.shipstation_settings.shipstation_settings Error: cannot import name '_Union' from 'typing' (/home/frappe/.pyenv/versions/3.9.9/lib/python3.9/typing.py))
Traceback (most recent call last):
  File "apps/frappe/frappe/modules/utils.py", line 238, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "apps/frappe/frappe/__init__.py", line 1191, in get_module
    return importlib.import_module(modulename)
  File "/home/frappe/.pyenv/versions/3.9.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "apps/shipstation_integration/shipstation_integration/shipstation_integration/doctype/shipstation_settings/shipstation_settings.py", line 8, in <module>
    from shipstation import ShipStation
  File "env/lib/python3.9/site-packages/shipstation/__init__.py", line 11, in <module>
    from shipstation.api import ShipStation
  File "env/lib/python3.9/site-packages/shipstation/api.py", line 10, in <module>
    from shipstation.base import ShipStationBase
  File "env/lib/python3.9/site-packages/shipstation/base.py", line 8, in <module>
    import cattr
  File "env/lib/python3.9/site-packages/cattr/__init__.py", line 2, in <module>
    from .converters import Converter, UnstructureStrategy
  File "env/lib/python3.9/site-packages/cattr/converters.py", line 15, in <module>
    from ._compat import (
  File "env/lib/python3.9/site-packages/cattr/_compat.py", line 87, in <module>
    from typing import _Union
ImportError: cannot import name '_Union' from 'typing' (/home/frappe/.pyenv/versions/3.9.9/lib/python3.9/typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 293, in install_app
    _install_app(app, verbose=context.verbose)
  File "apps/frappe/frappe/installer.py", line 186, in install_app
    sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True)
  File "apps/frappe/frappe/model/sync.py", line 75, in sync_for
    import_file_by_path(
  File "apps/frappe/frappe/modules/import_file.py", line 146, in import_file_by_path
    import_doc(
  File "apps/frappe/frappe/modules/import_file.py", line 275, in import_doc
    doc.insert()
  File "apps/frappe/frappe/model/document.py", line 291, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1085, in run_post_save_methods
    self.run_method("on_update")
  File "apps/frappe/frappe/model/document.py", line 941, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1260, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1242, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 938, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 376, in on_update
    self.run_module_method("on_doctype_update")
  File "apps/frappe/frappe/core/doctype/doctype/doctype.py", line 435, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "apps/frappe/frappe/modules/utils.py", line 240, in load_doctype_module
    raise ImportError(
ImportError: Module import failed for Shipstation Settings (shipstation_integration.shipstation_integration.doctype.shipstation_settings.shipstation_settings Error: cannot import name '_Union' from 'typing' (/home/frappe/.pyenv/versions/3.9.9/lib/python3.9/typing.py))
agritheory commented 2 years ago

@batonac Downgrade your python version. Frappe V13 should be running against 3.8 and no other major version. Reference: https://discuss.erpnext.com/t/dropping-python-3-7-support-for-next-version-of-frappe-erpnext/84803/4

batonac commented 2 years ago

That's so interesting, this is simply running in the default frappe_docker container... https://github.com/frappe/frappe_docker/tree/main/development

agritheory commented 2 years ago

The default docker container is going to be set for the latest development branch, which is V14 beta, but will soon be V15. This application only supports V13. We can't support V14 before its finalized.

batonac commented 2 years ago

I see... well, they only publish one version of the frappe/bench container, so apparently I need to find a different solution for local dev... Thanks

agritheory commented 2 years ago

I believe version is available as command line argument in the docker compose command, but I don't use it so I'm not a great source of information on this.

batonac commented 2 years ago

True, but it's still pulling a Debian Bullseye container, hence the dead-end here. I just set it up in a Ubuntu 20.04 VPS instead. Thanks