Skip to content

Windows上Duckdb冲突导致无法使用 #1797

@Xikcn

Description

@Xikcn

System Info

windows11,uv-python3.10.17,pandasai>=3.0.0b2,pandasai-litellm

🐛 Describe the bug

由于Duckdb库导致execute_sql_query函数无法正常使用

import pandasai as pai
from pandasai_litellm.litellm import LiteLLM

llm = LiteLLM(api_key="sk-xx",
    api_base="https://ai-api.gomd.cn/v1",
    model="openai/moonshotai/Kimi-K2-Instruct")


pai.config.set({
    "llm": llm

})

# Sample DataFrame
df = pai.DataFrame({
    "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
    "gdp": [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360, 1607402389504, 1490967855104, 4380756541440, 14631844184064],
    "happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12]
})

df.chat(prompt='Which are the top 5 countries by sales?')
[Windows 上的崩溃和错误](https://duckdb.org/docs/stable/clients/python/known_issues#crashes-and-errors-on-windows)
When importing DuckDB on Windows, the Python runtime may crash or return an error upon import or first use:
在 Windows 上导入 DuckDB 时,Python 运行时可能会在导入或首次使用时崩溃或返回错误:

import duckdb

duckdb.sql("...")

ImportError: DLL load failed while importing duckdb: The specified module could not be found.
Windows fatal exception: access violation

Current thread 0x0000311c (most recent call first):
  File "<stdin>", line 1 in <module>
Process finished with exit code -1073741819 (0xC0000005)
The problem is likely caused by using an outdated Microsoft Visual C++ (MSVC) Redistributable package. The solution is to install the [latest MSVC Redistributable package](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist). Alternatively, you can instruct pip to compile the package from source as follows:
该问题可能是由于使用过时的 Microsoft Visual C++ (MSVC) 可再发行包引起的。解决方案是安装[最新的 MSVC 可再发行包 ](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist)。 或者,您可以指示 pip 从源代码编译包,如下所示:

python3 -m pip install duckdb --no-binary duckdb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions