Skip to content

Quickstart error when following Python example without polars installed #247

@snissn

Description

@snissn

I was following the LanceDB quickstart from:

https://docs.lancedb.com/quickstart

After installing LanceDB with:

pip install lancedb

I copied the Python quickstart example and ran it. The example worked until the query result was converted with .to_polars(), at which point it failed because polars was not installed.

Error

Traceback (most recent call last):
  File "run.py", line 19, in <module>
    result = table.search(query_vector).limit(2).to_polars()
  File ".../site-packages/lancedb/query.py", line 807, in to_polars
    import polars as pl
ModuleNotFoundError: No module named 'polars'

Environment

Python: 3.10
LanceDB: 0.30.2
OS: Linux x86_64
Install command: pip install lancedb

Workaround

Installing polars separately resolved the issue:

pip install polars

After that, the quickstart example ran successfully and returned the expected result.

Suggested fix

The quickstart currently uses:

result = table.search(query_vector).limit(2).to_polars()

But polars does not appear to be installed by default with:

pip install lancedb

A few possible fixes:

  1. Update the quickstart install command to include polars, for example:
pip install lancedb polars
  1. Mention that .to_polars() requires installing polars separately.

  2. Make polars part of the default lancedb install, if .to_polars() is intended to be used in the main quickstart path.

  3. Use a default output method in the quickstart that works with the base lancedb installation, such as .to_list(), if that is preferred for the minimal path.

The current behavior is easy to work around, but it may trip up users who are naively following the quickstart from a clean environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions