simonw/llm

Homebrew release can't install plugins that use PyTorch (no PyTorch for Python 3.12 yet)

jernst opened this issue ยท 20 comments

macOS Sonoma 14.0, M1 Pro

$ brew install llm
<skipped, no issues>
$ llm
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.11_1/libexec/lib/python3.12/site-packages/llm/__init__.py", line 18, in <module>
    from .plugins import pm
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/llm/plugins.py", line 37, in <module>
    mod = importlib.import_module(plugin)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.0/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.11_1/libexec/lib/python3.12/site-packages/llm/default_plugins/openai_models.py", line 6, in <module>
    import openai
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/openai/__init__.py", line 19, in <module>
    from openai.api_resources import (
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/openai/api_resources/__init__.py", line 1, in <module>
    from openai.api_resources.audio import Audio  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/openai/api_resources/audio.py", line 4, in <module>
    from openai import api_requestor, util
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/openai/api_requestor.py", line 24, in <module>
    import requests
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/requests/__init__.py", line 147, in <module>
    from . import packages, utils
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/requests/utils.py", line 24, in <module>
    from . import certs
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/requests/certs.py", line 14, in <module>
    from certifi import where
ModuleNotFoundError: No module named 'certifi'

If I go and run:

$ brew install python-certifi

and try again:

$ llm
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.11_1/libexec/lib/python3.12/site-packages/llm/__init__.py", line 18, in <module>
    from .plugins import pm
  File "/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages/llm/plugins.py", line 37, in <module>
    mod = importlib.import_module(plugin)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.0/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.11_1/libexec/lib/python3.12/site-packages/llm/default_plugins/openai_models.py", line 17, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

So I do:

$ brew install pyyaml

and now we are in business.

This is really weird. I think it broke because of this: Homebrew/homebrew-core@5b121bf

What's surprising is that bottle still depends on pyyaml so I would expect it to continue working.

"An AI to fix dependency hell". One can wish :-)

Another issue, maybe similar root cause? The error message makes no sense to me. Torch is installed.

$ llm install llm-embed-jina
WARNING: Skipping /opt/homebrew/lib/python3.12/site-packages/packaging-23.2.dist-info due to invalid metadata entry 'name'
Collecting llm-embed-jina
  Using cached llm_embed_jina-0.1.2-py3-none-any.whl.metadata (3.0 kB)
Requirement already satisfied: llm in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm-embed-jina) (0.11)
Collecting transformers (from llm-embed-jina)
  Using cached transformers-4.34.1-py3-none-any.whl.metadata (121 kB)
INFO: pip is looking at multiple versions of llm-embed-jina to determine which version is compatible with other requirements. This could take a while.
Collecting llm-embed-jina
  Using cached llm_embed_jina-0.1.1-py3-none-any.whl.metadata (3.0 kB)
  Using cached llm_embed_jina-0.1-py3-none-any.whl.metadata (3.0 kB)
ERROR: Cannot install llm-embed-jina==0.1, llm-embed-jina==0.1.1 and llm-embed-jina==0.1.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    llm-embed-jina 0.1.2 depends on torch
    llm-embed-jina 0.1.1 depends on torch
    llm-embed-jina 0.1 depends on torch

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

What version of Torch do you have installed?

I have a new plugin that may help debug this. Could you report what you see when you run the following?

llm install llm-python
llm python --version
llm python -m pip freeze
llm python -c 'import sys; print(sys.path)'
$ llm install llm-python
WARNING: Skipping /opt/homebrew/lib/python3.12/site-packages/packaging-23.2.dist-info due to invalid metadata entry 'name'
Collecting llm-python
  Downloading llm_python-0.1-py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: llm in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm-python) (0.11)
Requirement already satisfied: click in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (8.1.7)
Requirement already satisfied: openai in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (0.28.1)
Requirement already satisfied: click-default-group>=1.2.3 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (1.2.4)
Requirement already satisfied: sqlite-utils>=3.35.0 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (3.35.1)
Requirement already satisfied: sqlite-migrate>=0.1a2 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (0.1a2)
Requirement already satisfied: pydantic>=1.10.2 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (2.4.2)
Requirement already satisfied: PyYAML in /opt/homebrew/opt/pyyaml/lib/python3.12/site-packages (from llm->llm-python) (6.0.1)
Requirement already satisfied: pluggy in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (1.3.0)
Requirement already satisfied: python-ulid in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (2.2.0)
Requirement already satisfied: setuptools in /opt/homebrew/opt/python-setuptools/lib/python3.12/site-packages (from llm->llm-python) (68.2.2)
Requirement already satisfied: pip in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm->llm-python) (23.3.1)
Requirement already satisfied: annotated-types>=0.4.0 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from pydantic>=1.10.2->llm->llm-python) (0.6.0)
Requirement already satisfied: pydantic-core==2.10.1 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from pydantic>=1.10.2->llm->llm-python) (2.10.1)
Requirement already satisfied: typing-extensions>=4.6.1 in /opt/homebrew/opt/python-typing-extensions/lib/python3.12/site-packages (from pydantic>=1.10.2->llm->llm-python) (4.8.0)
Requirement already satisfied: sqlite-fts4 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from sqlite-utils>=3.35.0->llm->llm-python) (1.0.3)
Requirement already satisfied: tabulate in /opt/homebrew/opt/python-tabulate/lib/python3.12/site-packages (from sqlite-utils>=3.35.0->llm->llm-python) (0.0.0)
Requirement already satisfied: python-dateutil in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from sqlite-utils>=3.35.0->llm->llm-python) (2.8.2)
Requirement already satisfied: requests>=2.20 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from openai->llm->llm-python) (2.31.0)
Requirement already satisfied: tqdm in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from openai->llm->llm-python) (4.66.1)
Requirement already satisfied: aiohttp in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from openai->llm->llm-python) (3.9.0b0)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from requests>=2.20->openai->llm->llm-python) (3.3.0)
Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from requests>=2.20->openai->llm->llm-python) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from requests>=2.20->openai->llm->llm-python) (2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/opt/python-certifi/lib/python3.12/site-packages (from requests>=2.20->openai->llm->llm-python) (2023.7.22)
Requirement already satisfied: attrs>=17.3.0 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from aiohttp->openai->llm->llm-python) (23.1.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from aiohttp->openai->llm->llm-python) (6.0.4)
Requirement already satisfied: yarl<2.0,>=1.0 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from aiohttp->openai->llm->llm-python) (1.9.2)
Requirement already satisfied: frozenlist>=1.1.1 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from aiohttp->openai->llm->llm-python) (1.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from aiohttp->openai->llm->llm-python) (1.3.1)
Requirement already satisfied: six>=1.5 in /opt/homebrew/opt/six/lib/python3.12/site-packages (from python-dateutil->sqlite-utils>=3.35.0->llm->llm-python) (1.16.0)
Downloading llm_python-0.1-py3-none-any.whl (7.2 kB)
WARNING: Skipping /opt/homebrew/lib/python3.12/site-packages/packaging-23.2.dist-info due to invalid metadata entry 'name'
Installing collected packages: llm-python
Successfully installed llm-python-0.1

$ llm python --version
Python 3.12.0

$ llm python -m pip freeze
WARNING: Skipping /opt/homebrew/lib/python3.12/site-packages/packaging-23.2.dist-info due to invalid metadata entry 'name'
aiohttp @ file:///private/tmp/llm--aiohttp-20231017-7840-bq6oe6/aiohttp-3.9.0b0
aiosignal @ file:///private/tmp/llm--aiosignal-20231017-7840-12be87i/aiosignal-1.3.1
annotated-types @ file:///private/tmp/llm--annotated-types-20231017-7840-10aemvu/annotated_types-0.6.0
async-timeout @ file:///private/tmp/llm--async-timeout-20231017-7840-hx3azw/async-timeout-4.0.3
attrs @ file:///private/tmp/llm--attrs-20231017-7840-184pp0g/attrs-23.1.0
certifi @ file:///private/tmp/python-certifi-20231008-5561-13s00fm/certifi-2023.7.22
cffi @ file:///private/tmp/cffi-20231014-5567-1hyue8f/cffi-1.16.0
charset-normalizer @ file:///private/tmp/llm--charset-normalizer-20231017-7840-q02a0/charset-normalizer-3.3.0
click @ file:///private/tmp/llm--click-20231017-7840-1yrbuo6/click-8.1.7
click-default-group @ file:///private/tmp/llm--click-default-group-20231017-7840-pky5al/click_default_group-1.2.4
frozenlist @ file:///private/tmp/llm--frozenlist-20231017-7840-1s47wso/frozenlist-1.4.0
idna @ file:///private/tmp/llm--idna-20231017-7840-kacneb/idna-3.4
llm @ file:///private/tmp/llm-20231017-7840-75hpu6/llm-0.11
llm-python==0.1
multidict @ file:///private/tmp/llm--multidict-20231017-7840-exe8fs/multidict-6.0.4
numpy==1.26.1
openai @ file:///private/tmp/llm--openai-20231017-7840-j9r307/openai-0.28.1
pluggy @ file:///private/tmp/llm--pluggy-20231017-7840-1bmig6y/pluggy-1.3.0
psutil @ file:///private/tmp/python-psutil-20231015-5378-1ng7p6p/psutil-5.9.6
pybind11 @ file:///private/tmp/pybind11-20231006-5480-1dj4kz4/pybind11-2.11.1
pycparser @ file:///private/tmp/pycparser-20231013-5787-1anpge2/pycparser-2.21
pydantic @ file:///private/tmp/llm--pydantic-20231017-7840-k1fzn3/pydantic-2.4.2
pydantic_core @ file:///private/tmp/llm--pydantic-core-20231017-7840-1ly5xrz/pydantic_core-2.10.1
Pygments @ file:///private/tmp/pygments-20231008-5534-zuvwpt/Pygments-2.16.1
python-dateutil @ file:///private/tmp/llm--python-dateutil-20231017-7840-mje5l3/python-dateutil-2.8.2
python-ulid @ file:///private/tmp/llm--python-ulid-20231017-7840-hoozhz/python_ulid-2.2.0
PyYAML @ file:///private/tmp/pyyaml-20231018-5610-1rdh755/PyYAML-6.0.1
requests @ file:///private/tmp/llm--requests-20231017-7840-175tsjh/requests-2.31.0
setuptools @ file:///private/tmp/python-setuptools-20231003-4907-14z3gk2/setuptools-68.2.2
six==1.16.0
sqlite-fts4 @ file:///private/tmp/llm--sqlite-fts4-20231017-7840-10814sr/sqlite-fts4-1.0.3
sqlite-migrate @ file:///private/tmp/llm--sqlite-migrate-20231017-7840-bgnd5e/sqlite-migrate-0.1a2
sqlite-utils @ file:///private/tmp/llm--sqlite-utils-20231017-7840-go4eg/sqlite-utils-3.35.1
tabulate @ file:///private/tmp/python-tabulate-20231006-5326-1cgwovj/tabulate-0.9.0
tqdm @ file:///private/tmp/llm--tqdm-20231017-7840-gnso9c/tqdm-4.66.1
typing_extensions @ file:///private/tmp/python-typing-extensions-20231008-5501-1ralzsu/typing_extensions-4.8.0
urllib3 @ file:///private/tmp/llm--urllib3-20231017-7840-hfx6ru/urllib3-2.0.7
wheel @ file:///opt/homebrew/Cellar/python%403.12/3.12.0/libexec/wheel-0.41.2-py3-none-any.whl#sha256=78d96cd4af1dba478ba60defeb048271977eec315912b78273611989471ec2f6
yarl @ file:///private/tmp/llm--yarl-20231017-7840-19cxwzy/yarl-1.9.2

$ llm python -c 'import sys; print(sys.path)'
['', '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python312.zip', '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12', '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload', '/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages', '/opt/homebrew/opt/python-setuptools/lib/python3.12/site-packages', '/opt/homebrew/opt/six/lib/python3.12/site-packages', '/opt/homebrew/opt/pygments/lib/python3.12/site-packages', '/opt/homebrew/opt/python-certifi/lib/python3.12/site-packages', '/opt/homebrew/opt/python-tabulate/lib/python3.12/site-packages', '/opt/homebrew/opt/python-typing-extensions/lib/python3.12/site-packages', '/opt/homebrew/opt/pyyaml/lib/python3.12/site-packages', '/opt/homebrew/lib/python3.12/site-packages', '/opt/homebrew/Cellar/pybind11/2.11.1/libexec/lib/python3.12/site-packages']

$ brew info pytorch
==> pytorch: stable 2.0.1 (bottled)

That sys.path is interesting:

['',
 '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python312.zip',
 '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12',
 '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload',
 '/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-setuptools/lib/python3.12/site-packages',
 '/opt/homebrew/opt/six/lib/python3.12/site-packages',
 '/opt/homebrew/opt/pygments/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-certifi/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-tabulate/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-typing-extensions/lib/python3.12/site-packages',
 '/opt/homebrew/opt/pyyaml/lib/python3.12/site-packages',
 '/opt/homebrew/lib/python3.12/site-packages',
 '/opt/homebrew/Cellar/pybind11/2.11.1/libexec/lib/python3.12/site-packages'
 ]

It's got the virtual environment for llm on there - /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages - but there are a whole bunch of other things too. I wonder if that's why it's getting confused about torch versions.

Here's what I get from the same command:

/opt/homebrew/bin/llm python -c 'import sys; from pprint import pprint; pprint(sys.path)'
['',
 '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python312.zip',
 '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12',
 '/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload',
 '/opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-setuptools/lib/python3.12/site-packages',
 '/opt/homebrew/opt/six/lib/python3.12/site-packages',
 '/opt/homebrew/opt/pygments/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-certifi/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-tabulate/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-typing-extensions/lib/python3.12/site-packages',
 '/opt/homebrew/opt/pyyaml/lib/python3.12/site-packages',
 '/opt/homebrew/opt/python-tabulate/lib/python3.12/site-packages',
 '/opt/homebrew/lib/python3.12/site-packages']

It's identical to yours with the exception of that last line, which you have and I do not have:

'/opt/homebrew/Cellar/pybind11/2.11.1/libexec/lib/python3.12/site-packages'

https://pypi.org/project/pybind11/ is "Seamless operability between C++11 and Python".

I ran brew install pybind11 so I could see what's in that folder.

cd /opt/homebrew/Cellar/pybind11/2.11.1/libexec/lib/python3.12/site-packages
find .

Output:

.
./pybind11
./pybind11/setup_helpers.py
./pybind11/_version.py
./pybind11/include
./pybind11/include/pybind11
./pybind11/include/pybind11/attr.h
./pybind11/include/pybind11/embed.h
./pybind11/include/pybind11/numpy.h
./pybind11/include/pybind11/pybind11.h
./pybind11/include/pybind11/operators.h
./pybind11/include/pybind11/iostream.h
./pybind11/include/pybind11/gil.h
./pybind11/include/pybind11/chrono.h
./pybind11/include/pybind11/stl_bind.h
./pybind11/include/pybind11/buffer_info.h
./pybind11/include/pybind11/options.h
./pybind11/include/pybind11/eigen
./pybind11/include/pybind11/eigen/matrix.h
./pybind11/include/pybind11/eigen/common.h
./pybind11/include/pybind11/eigen/tensor.h
./pybind11/include/pybind11/stl
./pybind11/include/pybind11/stl/filesystem.h
./pybind11/include/pybind11/functional.h
./pybind11/include/pybind11/stl.h
./pybind11/include/pybind11/detail
./pybind11/include/pybind11/detail/type_caster_base.h
./pybind11/include/pybind11/detail/typeid.h
./pybind11/include/pybind11/detail/descr.h
./pybind11/include/pybind11/detail/internals.h
./pybind11/include/pybind11/detail/common.h
./pybind11/include/pybind11/detail/class.h
./pybind11/include/pybind11/detail/init.h
./pybind11/include/pybind11/common.h
./pybind11/include/pybind11/eval.h
./pybind11/include/pybind11/cast.h
./pybind11/include/pybind11/type_caster_pyobject_ptr.h
./pybind11/include/pybind11/eigen.h
./pybind11/include/pybind11/pytypes.h
./pybind11/include/pybind11/complex.h
./pybind11/__init__.py
./pybind11/py.typed
./pybind11/commands.py
./pybind11/__main__.py
./pybind11/share
./pybind11/share/pkgconfig
./pybind11/share/pkgconfig/pybind11.pc
./pybind11/share/cmake
./pybind11/share/cmake/pybind11
./pybind11/share/cmake/pybind11/pybind11NewTools.cmake
./pybind11/share/cmake/pybind11/pybind11Targets.cmake
./pybind11/share/cmake/pybind11/pybind11Tools.cmake
./pybind11/share/cmake/pybind11/pybind11ConfigVersion.cmake
./pybind11/share/cmake/pybind11/FindPythonLibsNew.cmake
./pybind11/share/cmake/pybind11/pybind11Config.cmake
./pybind11/share/cmake/pybind11/pybind11Common.cmake
./pybind11-2.11.1.dist-info
./pybind11-2.11.1.dist-info/RECORD
./pybind11-2.11.1.dist-info/LICENSE
./pybind11-2.11.1.dist-info/direct_url.json
./pybind11-2.11.1.dist-info/WHEEL
./pybind11-2.11.1.dist-info/entry_points.txt
./pybind11-2.11.1.dist-info/top_level.txt
./pybind11-2.11.1.dist-info/REQUESTED
./pybind11-2.11.1.dist-info/INSTALLER
./pybind11-2.11.1.dist-info/METADATA

OK yes! I have recreated the bug.

/opt/homebrew/bin/llm install llm-embed-jina

Output:

Collecting llm-embed-jina
  Obtaining dependency information for llm-embed-jina from https://files.pythonhosted.org/packages/4c/10/0332ef43aa532cd1bdab8195174641454da52de008e03c031f6e3a6719a0/llm_embed_jina-0.1.2-py3-none-any.whl.metadata
  Using cached llm_embed_jina-0.1.2-py3-none-any.whl.metadata (3.0 kB)
Requirement already satisfied: llm in /opt/homebrew/Cellar/llm/0.11_1/libexec/lib/python3.12/site-packages (from llm-embed-jina) (0.11)
Collecting transformers (from llm-embed-jina)
  Obtaining dependency information for transformers from https://files.pythonhosted.org/packages/c1/bd/f64d67df4d3b05a460f281defe830ffab6d7940b7ca98ec085e94e024781/transformers-4.34.1-py3-none-any.whl.metadata
  Using cached transformers-4.34.1-py3-none-any.whl.metadata (121 kB)
INFO: pip is looking at multiple versions of llm-embed-jina to determine which version is compatible with other requirements. This could take a while.
Collecting llm-embed-jina
  Obtaining dependency information for llm-embed-jina from https://files.pythonhosted.org/packages/6c/fb/ed7c2b455a09bedf715857d24204869b8ce32df839eb848bed195df1af0a/llm_embed_jina-0.1.1-py3-none-any.whl.metadata
  Using cached llm_embed_jina-0.1.1-py3-none-any.whl.metadata (3.0 kB)
  Obtaining dependency information for llm-embed-jina from https://files.pythonhosted.org/packages/8b/1f/1187191401ac47bb850176e889b5decf2dae45f101e83c0fe3b64a5852d4/llm_embed_jina-0.1-py3-none-any.whl.metadata
  Using cached llm_embed_jina-0.1-py3-none-any.whl.metadata (3.0 kB)
ERROR: Cannot install llm-embed-jina==0.1, llm-embed-jina==0.1.1 and llm-embed-jina==0.1.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    llm-embed-jina 0.1.2 depends on torch
    llm-embed-jina 0.1.1 depends on torch
    llm-embed-jina 0.1 depends on torch

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: /opt/homebrew/Cellar/llm/0.11_1/libexec/bin/python -m pip install --upgrade pip

Aha!

/opt/homebrew/bin/llm python -m pip install torch
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: /opt/homebrew/Cellar/llm/0.11_1/libexec/bin/python -m pip install --upgrade pip

I bet there's no PyPI release for torch on Python 3.12 yet.

Yes! That's the problem: https://pypi.org/project/torch/2.1.0/#files

CleanShot 2023-10-27 at 18 54 48@2x

I've stopped recommending Homebrew installation for the moment. I updated my blog entry too: https://simonwillison.net/2023/Oct/26/llm-embed-jina/

Installing Python apps via Homebrew is generally problematic, has been for me anyway. Brew likes to update Python as often as it updates the other packages in the system, and library dependencies get incrementally out of sync. As Brew does not run pip upgrades. What works today might silently break tomorrow after the next Brew update run.

Also, managing a more mainstream Python distribution such as 3.11 along with the latest that Brew might install (is it 3.12 now?) leads to mysterious errors, because indeed the ML related PyPI packages tend to not work with the very latest Python. Often the same with the latest CUDA toolkit.

I think you've found a systematic problem in this rabbit hole.

Somehow gently guiding users to a venv or conda setup makes things much more stable but also more complicated for newcomers. Not sure what the silver bullet for usability is here, without turning the QuickStart into a small venv tutorial.

Some repos just include the venv commands as part of the README flow, but then don't mention what it does. Which is not obvious for getting-started level newcomers.

Optimally the README would provide some guidance for an environment-managed upgrade flow, so that later installing something else along with llm does not break llm running in the same env.

My problem here is that I want my tools to be possible to work with zero knowledge of Python at all. Conda and venv are very much tools for Python developers.

I thought I had that with Homebrew, but clearly there are some nasty traps waiting for people that way as well.

One option is I could start baking this stuff into Datasette Desktop, which would give me the ability to maintain complete control over the bundled Python without it conflicting with whatever else is going on with their system.

Ooof, ran into some sort of homebrew python issue.

Would it be possible to compile the project into a single binary that includes python? I know it's overhead size wise but that's what I ended up doing for some node.js utilities and UX seems to be better for folks that way.

I ran into this when installing via pipx too, perhaps because I also recently installed pipx to my machine and it may have resolved to python3.12 unlike most others. Perhaps llm plugins, if they require torch, should also declare

python_requires=">=3.7,<3.12",

until torch supports >=3.12 in setup.py or pyproject.toml which may make the error more explicit.

in any case, torch appears to be available for py3.12 in nightly build ref: pytorch/pytorch#110436 (comment)

and this works on my M2 mac

> llm install llm-python
> llm python -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
> llm install llm-sentence-transformers

Here's the PyTorch tracking issue: