Bridgeconn / usfm-grammar

An elegant USFM parser.
https://usfmgrammar.vachanengine.org/
MIT License
36 stars 14 forks source link

Error on usfm_parser import due to file path #232

Closed robertsonbrinker closed 5 months ago

robertsonbrinker commented 5 months ago

Using usfm-grammar 3.0.0b4 for python, when I declare from usfm_grammar import USFMParser, I get the following error:

FileNotFoundError: Could not find module '<contextlib._GeneratorContextManager object at 0x0000026CE090CF90>' (or one of its dependencies). Try using the full path with constructor syntax.

The issue is on lines 53-54 of usfm_parser.py.

lang_file = resources.path('usfm_grammar','my-languages.so') USFM_LANGUAGE = Language(str(lang_file), 'usfm3')

str(lang_file) returns contextlib._GeneratorContextManager object at 0x0000026CE090CF90 rather than a path.

One solution that worked for me is to change it to: image

kavitharaju commented 5 months ago

Thank you for raising the issue and looking into it.

But I am unable to replicate the issue on my system... I use python 3.10 on Ubuntu OS. image

Could you please share your OS, Python version and any other relevant info, for us to understand why/where this issue might be occuring?

PS: As the fix you found working for you seems harmless, will be making that change soon.

robertsonbrinker commented 5 months ago

I'm using Poetry for dependency management. VSCode is my dev environment. Python Version: 3.11.7

OS Edition: Windows 11 Pro OS Version: 22H2

joelthe1 commented 5 months ago

I was able to reproduce this issue on my Mac. We have merged in your suggested fix and released: https://pypi.org/project/usfm-grammar/3.0.0b5/ . Please try it and let us know if this fixed it.

robertsonbrinker commented 5 months ago

I tried it and the fix worked, thank you!