You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在.NET中用PythonNet导入Pandas库报错“No Module named pandas”求助

.NET环境下使用PythonNet导入Pandas库报错"No Module named pandas"

在.NET环境中尝试通过PythonNet导入Pandas库时,始终触发错误提示No Module named pandas,以下是具体实现代码:

static void Main(string[] args)
{
    // Set the path to the Python DLL
    Environment.SetEnvironmentVariable("PYTHONNET_PYDLL", @"C:\Users\username\AppData\Local\Programs\Python\Python311-32\python311.dll", EnvironmentVariableTarget.Process);

    // Initialize Python engine
    PythonEngine.Initialize();

    // Use the Python Global Interpreter Lock (GIL)
    using (Py.GIL())
    {
        var currentDirectory = Directory.GetCurrentDirectory();
        var pythonFilePath = Path.GetFullPath(Path.Combine(currentDirectory, @"..\..\..\"));
        dynamic sys = Py.Import("sys");
        sys.path.append(pythonFilePath);

        dynamic pd = Py.Import("pandas"); // Error at this line

        dynamic pythonScript = Py.Import("mypythonscript");
        // Call the 'say_hello' function from the Python module
        dynamic result = pythonScript.return_dataset();

        // Print the result
        Console.WriteLine(result);

        // Print the result
        Console.WriteLine(result);
    }

    // Shutdown Python engine
    PythonEngine.Shutdown();
}

已尝试以下方法但未解决问题:

  • 查阅PythonNet官方文档,相关内容提及较少
  • 咨询ChatGPT

内容的提问来源于stack exchange,提问作者Not Not One

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 15:22:50