Bump python version to 3.9 -or- fix AttributeError: module 'importlib.resources' has no attribute 'files'
jeffrey-hicks opened this issue · 3 comments
jeffrey-hicks commented
I am trying to use typst-py in Python 3.8 because I'm having to run on an older computer temporarily. When I try using typst.compile(...) I get AttributeError: module 'importlib.resources' has no attribute 'files'
, which nearest I can track down is because the files attribute appears to have come about in Python 3.9. Importlib docs
PPakalns commented
Workaround using importlib_resources backport:
https://pypi.org/project/importlib-resources/
# Workaround to make new features available in python3.8 for typst library
import importlib.resources as importlib_res
import importlib_resources
setattr(importlib_res, "files", importlib_resources.files)
setattr(importlib_res, "as_file", importlib_resources.as_file)
jeffrey-hicks commented
Thank you very much for helping.
PPakalns commented
Fix doesn't work.
In reality importlib.resources are defined in python 3.8, therefore importlib_resources are not imported.