2017-08-03 52 views
0

我一直試圖在NiFi的ExecuteScript處理器中運行python腳本。雖然這裏的問題是我沒有服務器文件位置訪問權限,並且所有的python庫都安裝在「/ data/jython」,「/ data/jython/Lib/site-packages /」和「data/nltk」無法從Nifi ExecuteScript處理器中引用python庫

下面是我的python腳本的進口部分:

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 

我已經添加了路徑參考包/庫: enter image description here

繼承人的錯誤消息的截圖: enter image description here

有什麼我失蹤?我提到了另一個回答here,但無法弄清楚我的代碼有什麼問題。

回答

2

至於其他的答案州,阿帕奇NiFi的ExecuteScript處理器採用的Jython,不的Python。 Jython庫存在一個限制,它無法處理本地模塊(以.so結尾的模塊或編譯的C代碼等)。這很可能是pycountry模塊包含一些本地模塊。您可以試試NiFi Developers Mailing List here上由Matt Burgess提出的解決方法。

+0

我嘗試使用sys.path.append()添加庫路徑。還嘗試添加路徑到模塊目錄,但它不起作用。 – atulshgl

+0

正如@Andy上面所說,你使用的一些模塊使用本地編譯的代碼。看到mattyb的答案[這裏](https://stackoverflow.com/questions/40719469/import-modules-in-nifi-executescript/40722026#40722026) –

相關問題