beancount / smart_importer

Augment Beancount importers with machine learning functionality.
MIT License
248 stars 29 forks source link

ImportError undefined symbol _PyGen_Send #116

Closed johnmee closed 2 years ago

johnmee commented 2 years ago

I expect this is a peculiarity with my install environment, but... my bean-extract works just fine before I install this package, and fails with it, and works again when I uninstall.

Not sure if anyone can be much help, but throwing it out here just in case.

The level of complexity is high given that numpy and/or scipy have binaries that need a presence. (apt install gfortran libatlas-base-dev).

ubuntu 22.04 virtualenv and poetry asdf as well. beancount v2 a couple of personal importers.

In my pyproject.toml file, my importers are found via packages->include which is a problem?

packages = [
    {include = "myimporters"}
]
(money-AtkJRch3-py3.10) [1] Sun Sep 11 11:39 /mnt/john/projects/money/office (master)$ bean-extract my.config ~/Downloads/banking/
Traceback (most recent call last):
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/bin/bean-extract", line 8, in <module>
    sys.exit(extract_main())
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/beancount/ingest/scripts_utils.py", line 36, in extract_main
    return trampoline_to_ingest(extract)
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/beancount/ingest/scripts_utils.py", line 198, in trampoline_to_ingest
    return run_import_script_and_ingest(parser)
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/beancount/ingest/scripts_utils.py", line 234, in run_import_script_and_ingest
    mod = runpy.run_path(args.config)
  File "/home/john/.asdf/installs/python/3.10.7/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/john/.asdf/installs/python/3.10.7/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/john/.asdf/installs/python/3.10.7/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "mee.config", line 5, in <module>
    from smart_importer import apply_hooks, PredictPostings
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/smart_importer/__init__.py", line 4, in <module>
    from smart_importer.predictor import EntryPredictor
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/smart_importer/predictor.py", line 14, in <module>
    from sklearn.pipeline import FeatureUnion
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/sklearn/__init__.py", line 82, in <module>
    from .base import clone
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/sklearn/base.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/sklearn/utils/__init__.py", line 29, in <module>
    from .fixes import parse_version, threadpool_info
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/sklearn/utils/fixes.py", line 19, in <module>
    import scipy.stats
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/scipy/stats/__init__.py", line 391, in <module>
    from .stats import *
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/scipy/stats/stats.py", line 174, in <module>
    from scipy.spatial.distance import cdist
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/scipy/spatial/__init__.py", line 107, in <module>
    from . import distance, transform
  File "/home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/scipy/spatial/transform/__init__.py", line 19, in <module>
    from .rotation import Rotation, Slerp
ImportError: /home/john/.cache/pypoetry/virtualenvs/money-AtkJRch3-py3.10/lib/python3.10/site-packages/scipy/spatial/transform/rotation.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyGen_Send

I found some threads that seemed to blame the undefined_symbol on the version of python so I bumped it up to the current Python 3.10.7, but no joy.

johnmee commented 2 years ago

Ah, here we go, never mind... scipy 1.6.1 issues. I'm taking my python in the wrong direction: the "current" release of scipy does not support python 3.10!? and has the issue addressed this in scipy v1.7+.

https://github.com/scipy/scipy/issues/14826

johnmee commented 2 years ago

Solved with

[tool.poetry.dependencies]
python = ">=3.10,<3.11"
beancount = "latest"
scipy = ">=1.8"
smart-importer = "latest"