vscode jupyter notebook kernel crashes when running polars code

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

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật