simonw / llm-openrouter

LLM plugin for models hosted by OpenRouter
Apache License 2.0
68 stars 12 forks source link

This stopped working and now throws `No module named 'urllib3'` #9

Closed ibehnam closed 6 months ago

ibehnam commented 6 months ago

This used to work until about a month ago when it suddenly stopped working. This is the error I'm getting:

✨ llm keys set openrouter                                                                                                                  18:20:45
Traceback (most recent call last):
  File "/opt/homebrew/bin/llm", line 5, in <module>
    from llm.cli import cli
  File "/opt/homebrew/Cellar/llm/0.13.1_1/libexec/lib/python3.12/site-packages/llm/__init__.py", line 18, in <module>
    from .plugins import pm
  File "/opt/homebrew/Cellar/llm/0.13.1_1/libexec/lib/python3.12/site-packages/llm/plugins.py", line 17, in <module>
    pm.load_setuptools_entrypoints("llm")
  File "/opt/homebrew/Cellar/llm/0.13.1_1/libexec/lib/python3.12/site-packages/pluggy/_manager.py", line 414, in load_setuptools_entrypoints
    plugin = ep.load()
             ^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1_1/libexec/lib/python3.12/site-packages/llm_openrouter.py", line 7, in <module>
    import urllib3
ModuleNotFoundError: No module named 'urllib3'
ibehnam commented 6 months ago

Solved by llm install urllib3. Didn't know we could install Python dependencies through llm, but your workaround regarding Homebrew limitations made me think of this solution. pipx wouldn't let me install urllib3, saying that it's not a dependency for any package.

simonw commented 6 months ago

Thanks for the bug report, maybe this is a Python 3.12 thing? I'll add urllib3 as a direct dependency (once I recreate the bug).

ibehnam commented 6 months ago

@simonw Yes, it's Python 3.12. The bug actually was worse than I thought because once it happens, also messes with the other functionality of llm as well. Had to pipx uninstall it a few times as it wouldn't let me set the API keys either.

simonw commented 6 months ago

Actually I had a fix for this already, I just hadn't pushed it yet.