frankie567 / httpx-ws

WebSocket support for HTTPX
https://frankie567.github.io/httpx-ws/
MIT License
102 stars 12 forks source link

`ModuleNotFoundError: No module named 'httpcore.backends'` #35

Closed saforem2 closed 1 year ago

saforem2 commented 1 year ago

Describe the bug

Trying to run a different project jpterm and encountered the following traceback:

Traceback (most recent call last):
  File "/Users/samforeman/projects/saforem2/l2hmc-qcd/venvs/py310/bin/jpterm", line 5, in <module>
    from jpterm.cli import main
  File "/Users/samforeman/projects/jpterm/jpterm/cli.py", line 3, in <module>
    from txl.app import disabled
  File "/Users/samforeman/projects/jpterm/txl/txl/app.py", line 6, in <module>
    components = {
  File "/Users/samforeman/projects/jpterm/txl/txl/app.py", line 7, in <dictcomp>
    ep.name: ep.load()
  File "/Users/samforeman/projects/saforem2/l2hmc-qcd/venvs/py310/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2517, in load
    return self.resolve()
  File "/Users/samforeman/projects/saforem2/l2hmc-qcd/venvs/py310/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2523, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/samforeman/projects/saforem2/l2hmc-qcd/venvs/py310/lib/python3.10/site-packages/txl_remote_contents/components.py", line 9, in <module>
    from httpx_ws import aconnect_ws
  File "/Users/samforeman/projects/saforem2/l2hmc-qcd/venvs/py310/lib/python3.10/site-packages/httpx_ws/__init__.py", line 3, in <module>
    from httpx_ws._api import (
  File "/Users/samforeman/projects/saforem2/l2hmc-qcd/venvs/py310/lib/python3.10/site-packages/httpx_ws/_api.py", line 14, in <module>
    from httpcore.backends.base import AsyncNetworkStream, NetworkStream
ModuleNotFoundError: No module named 'httpcore.backends'

I've identified the problem to be coming from this line in your httpx_ws/_api.py:L14 file

https://github.com/frankie567/httpx-ws/blob/f0e4d4b124d3ca7b0a85178f8294c22542841ce5/httpx_ws/_api.py#L14

Replacing

from httpcore.backends.base import AsyncNetworkStream, NetworkStream

with

from httpcore._backends.base import AsyncNetworkStream, NetworkStream

resolved the issue.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Configuration

Additional context

Add any other context about the problem here.

wimglenn commented 1 year ago

Since v0.17.3 use

from httpcore import AsyncNetworkStream, NetworkStream

instead of

from httpcore.backends.base import AsyncNetworkStream, NetworkStream

ref: https://github.com/encode/httpcore/blob/master/CHANGELOG.md#0173-5th-july-2023

saforem2 commented 1 year ago

fixed and updated in #36

frankie567 commented 1 year ago

Thank you @saforem2 for raising this and @wimglenn for pointing out the fix :) That's the risk when we rely on private API 😅