我正在使用Jython执行一个python脚本connect_host.py该脚本使用paramiko模块连接到指定的主机。
paramiko模块内部使用Crypto模块,Crypto.Util模块使用 Counter.py,而反过来又尝试导入_counter,它存在于Crypto.Util的同一位置,但作为.so文件。
在执行时,python 会抛出以下错误:
File "/location/helper/connect_host.py", line 3, in <module>
import paramiko
File "/python/modules/paramiko/__init__.py", line 69, in <module>
from transport import SecurityOptions, Transport
File "/python/modules/paramiko/transport.py", line 32, in <module>
from paramiko import util
File "/python/modules/paramiko/util.py", line 32, in <module>
from paramiko.common import *
File "/python/modules/paramiko/common.py", line 98, in <module>
from Crypto import Random
File "/python/modules/Crypto/Random/__init__.py", line 29, in <module>
from Crypto.Random import _UserFriendlyRNG
File "/python/modules/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
from Crypto.Random.Fortuna import FortunaAccumulator
File "/python/modules/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
import FortunaGenerator
File "/python/modules/Crypto/Random/Fortuna/FortunaGenerator.py", line 35, in <module>
from Crypto.Util import Counter
File "/python/modules/Crypto/Util/Counter.py", line 29, in <module>
from Crypto.Util import _counter
ImportError: cannot import name _counter
如何使Jython加载_counter模块,这是一个.so文件??????
在这个Python文档中,它说:
Jython是Java平台的Python语言的实现。Jython 2.7 实现了与 CPython 2.7 相同的语言....
。Jython程序目前无法使用用C编写的CPython扩展模块。这些模块通常具有扩展名为 .so、.pyd 或 .dll 的文件。
如果 import _counter
与 Crypto.Util
位于同一位置,但作为.so
文件存在,这将解释为什么它不会从 Jython 运行。