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

查看:222
本文介绍了在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文件等).根据此SO帖子,paramiko使用具有本机库的Crypto,因此无法在Jython中使用(请参见

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模块,其中有

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