Apache NiFi 中的 Python 错误:导入错误:没有名为 Pandas 的模块 [英] Python error in Apache NiFi: Import Error: No module named Pandas

查看:39
本文介绍了Apache NiFi 中的 Python 错误:导入错误:没有名为 Pandas 的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 NiFi 的新手.我正在尝试使用 ExecuteScript 处理器执行 Python 脚本.当我尝试一个没有导入命令的简单脚本时,它运行良好并在 nifi.StdOut 中显示输出.当我尝试运行包含导入命令(如 import pandas)的脚本时.它显示以下错误:

I'm new to NiFi. I'm trying to execute a Python script using ExecuteScript processor. When I tried a simple script which has no import commands it ran fine and showed output in nifi.StdOut. When I tried to run a script which includes import commands like import pandas. It showing the below error:

导入错误:没有名为 Pandas 的模块

Import Error: No module named Pandas

我尝试在属性的模块目录中提供 pkgs 的路径.但它不锻炼.任何帮助将不胜感激!

I tried providing the path of the pkgs in the Module directory in properties. But it doesn't workout. Any help would be appreciated!

推荐答案

我认为问题在于 Pandas 是一个本地编译的模块(它是用 C 编写的),而不是纯 Python.这是一个问题的原因是由于 JSR-223 引擎,Apache NiFi ExecuteScript 处理器使用 Jython 而不是实际的 Python.所以 Python 代码可以运行,但它不能依赖于非纯 Python 的模块.

I believe the issue is that pandas is a natively-compiled module (it is written in C) rather than being pure Python. The reason this is a problem is that due to the JSR-223 engine, the Apache NiFi ExecuteScript processor uses Jython rather than actual Python. So Python code is fine to run, but it can't depend on modules that aren't pure Python.

解决方法是使用 ExecuteStreamCommand 处理器通过命令行调用依赖于 Pandas 的 Python 脚本(即 python my_script_that_uses_pandas.py).流文件内容将流式传输到 STDIN 并从 STDOUT 捕获.这是一个相关答案,详细描述了这一点.

The workaround is to use the ExecuteStreamCommand processor to invoke the Python script which depends on pandas via the command-line (i.e. python my_script_that_uses_pandas.py). The flowfile content will be streamed to STDIN and captured from STDOUT. Here's a related answer describing this in detail.

这篇关于Apache NiFi 中的 Python 错误:导入错误:没有名为 Pandas 的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆