在 Nifi ExecuteScript 中导入模块 [英] Import Modules in Nifi ExecuteScript

查看:36
本文介绍了在 Nifi ExecuteScript 中导入模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Nifi 和 python 的新手

I am new to Nifi and python

我想执行我的python脚本.所以使用 ExecuteScript 并尝试导入某些模块.我是这样导入的:

i want to execute my python script. So used ExecuteScript and tried to import certain modules. I have imported like this:

import json, sftp, paramiko

虽然我已经安装了 sftp,但当我在 Executescript 中导入它时,它显示无法处理会话.在第 1 行没有名为 sftp 的模块"

Though i have sftp installed, When i import it in Executescript, it says "Failed to process session. No module named sftp at line number 1"

which -a sftp
/usr/bin/sftp

在导入 paramiko 时,也出现了同样的错误.

When importing paramiko also, got the same error.

推荐答案

ExecuteScript 和 InvokeScriptedProcessor 使用的python"引擎实际上是 Jython,而不是纯 Python.这意味着它无法加载本机模块(.so 文件、编译的 C 文件等).根据 this SO post, paramiko 使用具有原生库的 Crypto,因此不能在 Jython 中使用(参见 这篇文章 以供我对此发表评论).我的猜测是 sftp 库也是如此.

The "python" engine used by ExecuteScript and InvokeScriptedProcessor is actually Jython, not pure Python. This means it cannot load native modules (.so files, compiled C files, etc.). According to this SO post, paramiko uses Crypto which has native libraries, so cannot be used in Jython (see the bottom of this post for my comment on that). My guess is that the sftp library does the same.

Jython 可以使用纯 Python 模块,有 NiFi 邮件列表上的讨论关于如何指向(并包含)这些类型的模块.

Jython can make use of pure Python modules, there is a discussion on the NiFi mailing list about how to point at (and include) those kinds of modules.

这篇关于在 Nifi ExecuteScript 中导入模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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