anyio: ModuleNotFoundError: No module named 'anyio._backends'

I’m using asks under trio, and I’m compiling it to an .exe file with PyInstaller. Every time asks is run on the compiled .exe it returns the following error:

  File "site-packages\anyio\__init__.py", line 94, in _get_asynclib
KeyError: 'anyio._backends._trio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "myscript.py", line 324, in myfunction
  File "site-packages\asks\base_funcs.py", line 30, in request
  File "site-packages\asks\sessions.py", line 198, in request
  File "site-packages\asks\sessions.py", line 365, in sema
  File "site-packages\anyio\__init__.py", line 698, in create_semaphore
  File "site-packages\anyio\__init__.py", line 96, in _get_asynclib
  File "importlib\__init__.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'anyio._backends'
  • Platform: Windows-10-10.0.19041-SP0
  • PyInstaller: 3.6
  • Python: 3.8.0
  • Trio: 0.16.0
  • Asks: 2.4.8
  • Anyio 1.4.0

It’s already imported on the main function, I tried to hiddenimport it on a hook file and also manually when compiling, but it results the same.

Is anyio not compatible with PyInstaller? Or am I not seeing something?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments