question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'anyio._backends'

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

0reactions
agronholmcommented, Aug 5, 2020

I prefer the solution of collecting all backend modules automatically in the PyInstaller hook. This should not be a problem going forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

anyio · PyPI
AnyIO is an asynchronous networking and concurrency library that works on top of either ... It will blend in with native libraries of...
Read more >
ModuleNotFoundError: No module named 'anyio'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'anyio' How to remove the ModuleNotFou.
Read more >
Testing with AnyIO — AnyIO 1.4.0 documentation
Any coroutine fixture that is activated by a test marked with @pytest.mark.anyio will be run with the same backend as the test itself....
Read more >
How to fix "ModuleNotFoundError: No module named 'anyio'"
You must first install the package before you can use it in your code. Run the following command to install the package and...
Read more >
No module named when using PyInstaller - Stack Overflow
If you are getting ModuleNotFoundError: No module named ... errors and you: ... your own backend outside of matplotlib by # referring to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found