In VSCode, Created a new python project with a new Virtual environment. pip installed the polars package and executed a sample polars code from https://docs.pola.rs/user-guide/getting-started/. However the kernel is crashing repeatedly, if the code is executed. Please advice.
pip install polars
import polars as pl
from datetime import datetime
df = pl.DataFrame(
{
"integer": [1, 2, 3],
"date": [
datetime(2025, 1, 1),
datetime(2025, 1, 2),
datetime(2025, 1, 3),
],
"float": [4.0, 5.0, 6.0],
"string": ["a", "b", "c"],
}
)
print(df)
The Kernel crashed while executing code in the current cell or a previous cell.
Please review the code in the cell(s) to identify a possible cause of the failure.
Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info.
View Jupyter log for further details.
Adding further diagnostics from terminal…
Microsoft Windows [Version 10.0.19045.4780]
(c) Microsoft Corporation. All rights reserved.
(.venv) D:zikzakjackcodevscodesplayground_polars>pip install polars
Requirement already satisfied: polars in d:zikzakjackcodevscodesplayground_polars.venvlibsite-packages (1.6.0)
(.venv) D:zikzakjackcodevscodesplayground_polars>python
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars as pl
d:zikzakjackcodevscodesplayground_polars.venvLibsite-packagespolars_cpu_check.py:259: RuntimeWarning: Missing required CPU features.
The following required CPU features were not detected:
avx2, fma, bmi1, bmi2, lzcnt, movbe
Continuing to use this version of Polars on this processor will likely result in a crash.
Install the `polars-lts-cpu` package instead of `polars` to run Polars with better compatibility.
avx2, fma, bmi1, bmi2, lzcnt, movbe
Continuing to use this version of Polars on this processor will likely result in a crash.
Install the `polars-lts-cpu` package instead of `polars` to run Polars with better compatibility.
Hint: If you are on an Apple ARM machine (e.g. M1) this is likely due to running Python under Rosetta.
It is recommended to install a native version of Python that does not run under Rosetta x86-64 emulation.
If you believe this warning to be a false positive, you can set the `POLARS_SKIP_CPU_CHECK` environment variable to bypass this check.
warnings.warn(
2
Issue is because of Polars performing a cpu check. Mine is a way Old ASUS RoG Gaming Laptop bought in 2012. Thats possibly tripping some polars cpu check. Refer the link for more details: https://github.com/pola-rs/polars/issues/15404. Solution is to uninstall the polars package and use the polars-lts-cpu. I hope this solution helps someone with older cpu as mine.
step1: pip uninstall polars
step2: pip install polars-lts-cpu
Screenshot of working demo:
Further debugging based on suggestion from @orlp
current packages list
(venv_polars) D:zikzakjackvenvsvenv_polars>pip list
Package Version
---------- -------
pip 24.0
pyspark 3.5.2
setuptools 65.5.0
polars will not be available. fails as expected
(venv_polars) D:zikzakjackvenvsvenv_polars>python
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
>>> import polars as pl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'polars'
>>>
pip install polars-lts-cpu
(venv_polars) D:zikzakjackvenvsvenv_polars>pip install polars-lts-cpu
Collecting polars-lts-cpu
Using cached polars_lts_cpu-1.6.0-cp38-abi3-win_amd64.whl.metadata (14 kB)
Using cached polars_lts_cpu-1.6.0-cp38-abi3-win_amd64.whl (31.5 MB)
Installing collected packages: polars-lts-cpu
Successfully installed polars-lts-cpu-1.6.0
packages list after install
(venv_polars) D:zikzakjackvenvsvenv_polars>pip list
Package Version
-------------- -------
pip 24.0
polars-lts-cpu 1.6.0
pyspark 3.5.2
setuptools 65.5.0
try a polars sample without setting POLARS_SKIP_CPU_CHECK
works properly as indicated by the cpu check author @orlp.
(venv_polars) D:zikzakjackvenvsvenv_polars>python
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars as pl
>>> from datetime import datetime
>>>
>>> df = pl.DataFrame(
... {
... "integer": [1, 2, 3],
... "date": [
... datetime(2025, 1, 1),
... datetime(2025, 1, 2),
... datetime(2025, 1, 3),
... ],
... "float": [4.0, 5.0, 6.0],
... "string": ["a", "b", "c"],
... }
... )
>>>
>>> print(df)
shape: (3, 4)
┌─────────┬─────────────────────┬───────┬────────┐
│ integer ┆ date ┆ float ┆ string │
│ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ datetime[μs] ┆ f64 ┆ str │
╞═════════╪═════════════════════╪═══════╪════════╡
│ 1 ┆ 2025-01-01 00:00:00 ┆ 4.0 ┆ a │
│ 2 ┆ 2025-01-02 00:00:00 ┆ 5.0 ┆ b │
│ 3 ┆ 2025-01-03 00:00:00 ┆ 6.0 ┆ c │
└─────────┴─────────────────────┴───────┴────────┘
>>>
3