无法从 Nifi ExecuteScript 处理器引用 python 库 [英] Unable to refer python libraries from Nifi ExecuteScript processor

查看:29
本文介绍了无法从 Nifi ExecuteScript 处理器引用 python 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在 NiFi 的 ExecuteScript 处理器中运行 python 脚本.尽管这里的问题是我没有服务器文件位置访问权限,并且所有 python 库都安装在/data/jython"、/data/jython/Lib/site-packages/"和data/nltk"

I have been trying to run a python script in NiFi's ExecuteScript processor. Though the catch here is that I don't have server file location access and all the python libraries are installed at "/data/jython", "/data/jython/Lib/site-packages/" and "data/nltk"

下面是我的python脚本的导入部分:

Below is the import section of my python script:

import json, traceback, pycountry, requests, geocoder, re, sys, nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from nltk.corpus import stopwords
from java.nio.charset import StandardCharsets
from org.apache.commons.io import IOUtils
from org.apache.nifi.processor.io import StreamCallback
from org.python.core.util import StringUtil

我添加了对包/库的路径引用:

I have added path reference to the packages/libraries:

错误信息截图如下:

有什么我遗漏的吗?我在这里,但无法弄清楚我的代码有什么问题.

Is there something I am missing? I have referred to another answer here, but couldn't figure out whats wrong with my code.

推荐答案

正如其他答案所述,Apache NiFi 的 ExecuteScript 处理器使用 Jython,而不是 Python.Jython 库存在一个限制,即它无法处理本机模块(以 .so 结尾的模块或已编译的 C 代码等).pycountry 模块很可能包含一些本机模块.您可以尝试由 Matt Burgess 在 此处为 NiFi 开发人员邮件列表.

As the other answers state, Apache NiFi's ExecuteScript processor uses Jython, not Python. There is a limitation on the Jython library that it cannot handle native modules (modules that end in .so or are compiled C code, etc.). It is very likely that the pycountry module contains some native module. You can try a work-around proposed by Matt Burgess on the NiFi Developers Mailing List here.

这篇关于无法从 Nifi ExecuteScript 处理器引用 python 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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