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

查看:254
本文介绍了无法从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脚本的import部分:

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:

此处显示错误消息的屏幕截图:

Heres the screenshot of the error message:

有什么我想念的吗?我已经在此处引用了另一个答案>,但无法弄清楚我的代码出了什么问题.

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在

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天全站免登陆