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

查看:270
本文介绍了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

我尝试在属性的Module目录中提供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处理器通过命令行(即python my_script_that_uses_pandas.py)调用依赖于熊猫的Python脚本.流文件的内容将被流式传输到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天全站免登陆