Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'anyio._backends._curio' #2231

Closed
maingoh opened this issue May 17, 2022 · 0 comments
Closed

ModuleNotFoundError: No module named 'anyio._backends._curio' #2231

maingoh opened this issue May 17, 2022 · 0 comments

Comments

@maingoh
Copy link

maingoh commented May 17, 2022

The sample from the documentation does not seem to work with curio.
I get the following stacktrace:

**Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 153, in get_asynclib
    return sys.modules[modulename]
KeyError: 'anyio._backends._curio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 3, in main
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1729, in get
    return await self.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1506, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1593, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1621, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1658, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1695, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request
    status = RequestStatus(request)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 19, in __init__
    self._connection_acquired = AsyncEvent()
  File "/usr/local/lib/python3.8/site-packages/httpcore/_synchronization.py", line 29, in __init__
    self._event = anyio.Event()
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_synchronization.py", line 78, in __new__
    return get_asynclib().Event()
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 155, in get_asynclib
    return import_module(modulename)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  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._curio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 153, in get_asynclib
    return sys.modules[modulename]
KeyError: 'anyio._backends._curio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/curio/kernel.py", line 822, in run
    return kernel.run(corofunc, *args)
  File "/usr/local/lib/python3.8/site-packages/curio/kernel.py", line 172, in run
    raise ret_exc
  File "/usr/local/lib/python3.8/site-packages/curio/kernel.py", line 736, in kernel_run
    trap = current.send(current._trap_result)
  File "/usr/local/lib/python3.8/site-packages/curio/task.py", line 167, in send
    return self._send(value)
  File "/usr/local/lib/python3.8/site-packages/curio/task.py", line 171, in _task_runner
    return await coro
  File "<stdin>", line 4, in main
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1975, in __aexit__
    await self._transport.__aexit__(exc_type, exc_value, traceback)
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 332, in __aexit__
    await self._pool.__aexit__(exc_type, exc_value, traceback)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 326, in __aexit__
    await self.aclose()
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 303, in aclose
    async with self._pool_lock:
  File "/usr/local/lib/python3.8/site-packages/httpcore/_synchronization.py", line 15, in __aenter__
    await self._lock.acquire()
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_synchronization.py", line 121, in acquire
    await checkpoint_if_cancelled()
  File "/usr/local/lib/python3.8/site-packages/anyio/lowlevel.py", line 42, in checkpoint_if_cancelled
    await get_asynclib().checkpoint_if_cancelled()
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 155, in get_asynclib
    return import_module(modulename)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  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._curio'

It might be because httpx use anyio which does not support curio anymore ?

Can httpx support curio without using anyio ?

@encode encode locked and limited conversation to collaborators May 17, 2022
@florimondmanca florimondmanca converted this issue into discussion #2232 May 17, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant