Skip to content
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

Don't crash with a weird numpy version and "no attribute int8" #632

Closed
simonw opened this issue Jul 18, 2024 · 1 comment
Closed

Don't crash with a weird numpy version and "no attribute int8" #632

simonw opened this issue Jul 18, 2024 · 1 comment

Comments

@simonw
Copy link
Owner

simonw commented Jul 18, 2024

I've seen this too. It's really frustrating. I think the solution may be to add numpy as an explicit Homebrew dependency to avoid this from happening.

I'm going to fix this in sqlite-utils itself.

Originally posted by @simonw in simonw/llm#531 (comment)

@simonw simonw changed the title Don't crash with a weird numpy version andou "no attribute int8" Don't crash with a weird numpy version and "no attribute int8" Jul 18, 2024
@simonw
Copy link
Owner Author

simonw commented Jul 18, 2024

This bug showed up in LLM installed via Homebrew, but the core problem is this:

❯ llm --help
Traceback (most recent call last):
  File "/usr/local/bin/llm", line 5, in <module>
    from llm.cli import cli
  File "/usr/local/Cellar/llm/0.14/libexec/lib/python3.12/site-packages/llm/__init__.py", line 16, in <module>
    from .embeddings import Collection
  File "/usr/local/Cellar/llm/0.14/libexec/lib/python3.12/site-packages/llm/embeddings.py", line 7, in <module>
    from sqlite_utils import Database
  File "/usr/local/Cellar/llm/0.14/libexec/lib/python3.12/site-packages/sqlite_utils/__init__.py", line 4, in <module>
    from .db import Database
  File "/usr/local/Cellar/llm/0.14/libexec/lib/python3.12/site-packages/sqlite_utils/db.py", line 211, in <module>
    np.int8: "INTEGER",
    ^^^^^^^
AttributeError: module 'numpy' has no attribute 'int8'

From here:

if np:
COLUMN_TYPE_MAPPING.update(
{
np.int8: "INTEGER",
np.int16: "INTEGER",
np.int32: "INTEGER",
np.int64: "INTEGER",
np.uint8: "INTEGER",
np.uint16: "INTEGER",
np.uint32: "INTEGER",
np.uint64: "INTEGER",
np.float16: "FLOAT",
np.float32: "FLOAT",
np.float64: "FLOAT",
}
)

I'm not entirely sure how Homebrew ends up with a numpy that doesn't expose np.int8 but I can fix it here, since this is an optional import anyway.

simonw added a commit that referenced this issue Jul 18, 2024
@simonw simonw closed this as completed Jul 18, 2024
simonw added a commit that referenced this issue Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant