Skip to content

Can't import urllib3 #73

@jonas-w

Description

@jonas-w

I'm using jupyterlite and the xeus kernel.

When I run import urllib3 I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 import urllib3

File /lib/python3.11/site-packages/urllib3/__init__.py:209
    193     return _DEFAULT_POOL.request(
    194         method,
    195         url,
   (...)
    204         json=json,
    205     )
    208 if sys.platform == "emscripten":
--> 209     from .contrib.emscripten import inject_into_urllib3  # noqa: 401
    211     inject_into_urllib3()

File /lib/python3.11/site-packages/urllib3/contrib/emscripten/__init__.py:6
      3 import urllib3.connection
      5 from ...connectionpool import HTTPConnectionPool, HTTPSConnectionPool
----> 6 from .connection import EmscriptenHTTPConnection, EmscriptenHTTPSConnection
      9 def inject_into_urllib3() -> None:
     10     # override connection classes to use emscripten specific classes
     11     # n.b. mypy complains about the overriding of classes below
     12     # if it isn't ignored
     13     HTTPConnectionPool.ConnectionCls = EmscriptenHTTPConnection

File /lib/python3.11/site-packages/urllib3/contrib/emscripten/connection.py:17
     15 from ...util.timeout import _DEFAULT_TIMEOUT, _TYPE_TIMEOUT
     16 from ...util.url import Url
---> 17 from .fetch import _RequestError, _TimeoutError, send_request, send_streaming_request
     18 from .request import EmscriptenRequest
     19 from .response import EmscriptenHttpResponseWrapper, EmscriptenResponse

File /lib/python3.11/site-packages/urllib3/contrib/emscripten/fetch.py:319
    313 _fetcher: _StreamingFetcher | None = None
    315 if is_worker_available() and (
    316     (is_cross_origin_isolated() and not is_in_browser_main_thread())
    317     and (not is_in_node())
    318 ):
--> 319     _fetcher = _StreamingFetcher()
    320 else:
    321     _fetcher = None

File /lib/python3.11/site-packages/urllib3/contrib/emscripten/fetch.py:200, in _StreamingFetcher.__init__(self)
    195 def __init__(self) -> None:
    196     # make web-worker and data buffer on startup
    197     self.streaming_ready = False
    199     js_data_blob = js.Blob.new(
--> 200         [_STREAMING_WORKER_CODE], _obj_from_dict({"type": "application/javascript"})
    201     )
    203     def promise_resolver(js_resolve_fn: JsProxy, js_reject_fn: JsProxy) -> None:
    204         def onMsg(e: JsProxy) -> None:

File /lib/python3.11/site-packages/urllib3/contrib/emscripten/fetch.py:89, in _obj_from_dict(dict_val)
     88 def _obj_from_dict(dict_val: dict[str, Any]) -> JsProxy:
---> 89     return to_js(dict_val, dict_converter=js.Object.fromEntries)

TypeError: to_js() got an unexpected keyword argument 'dict_converter'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions