bnm3k / polars-fuzzy-match

Polars extension for fzf-style fuzzy matching
MIT License
20 stars 2 forks source link

usage.py failing: minimum polars version required? #4

Open abubelinha opened 8 months ago

abubelinha commented 8 months ago

Coming from #3 , where I tried installation on two different Windows machines. Both of them have now polars and polars-fuzzy-match v. 0.1.3

from polars_fuzzy_match import fuzzy_match_score

c:\python39\python polarex.py
Traceback (most recent call last):
  File "c:\python\polarex.py", line 78, in <module>
    polarsfm_usage(); sys.exit()
  File "c:\python\polarex.py", line 11, in polarsfm_usage
    from polars_fuzzy_match import fuzzy_match_score
  File "c:\python39\lib\site-packages\polars_fuzzy_match\__init__.py", line 4, in <module>
    from polars.type_aliases import IntoExpr
ModuleNotFoundError: No module named 'polars.type_aliases'
c:\Python38\python polarex.py
shape: (2, 2)
┌─────────────┬───────┐
│ strs        ┆ score │
│ ---         ┆ ---   │
│ str         ┆ u32   │
╞═════════════╪═══════╡
│ foo quz BAR ┆ 88    │
│ baaarfoo    ┆ 74    │
└─────────────┴───────┘

What could be the reason for this difference?

Both machines can run this very basic polars script without errors:

import polars as pl
localcsv = "sample.csv"
df = pl.read_csv(localcsv, infer_schema_length=2, ignore_errors=True)
print(df.sample(25))
print(df.describe())

Thanks a lot in advance @abubelinha

abubelinha commented 8 months ago

Update:

Now I recall a problem when I installed polars yesterday in Python 3.8 / Windows 7. Although pip installation was completed without errors, importing polars raised an error (something I don't recall, related to CPU) and suggesting to try this package instead (and that's what I did): pip installpolars-lts-cpu After doing that, polars example worked (and polars-fuzzy-match usage.py example works too).

My installation of polars in Python 3.9 / Windows 10 did not raise such polars importing error, so that machine has the normal polars pip package, and my polars read_csv example script works good.

Oddly, the "normal" installation is the one where polars-fuzzy-match usage.py example fails.

abubelinha commented 8 months ago

I guess this was related to polars version, which was older in my Python 3.9 machine. Something around 0.16? ... sorry I didn't annotate it, but I upgraded polars to 0.20.13 and now polars-fuzzy-match usage.py example is working.

Perhaps polars-fuzzy-match installation could take care of this? (in case you can confirm a minimum polars version is required)

bnm3k commented 8 months ago

Yeah, I was about to add that if the issue is that polars.type_aliases cannot be imported then the problem's most likely with polars rather than the plugin. But seems you've figured it out :)