2

我正在使用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 文件??????

4

1 回答 1

0

这个 Python 文档中它说:

Jython 是用于 Java 平台的 Python 语言的实现。Jython 2.7 实现与 CPython 2.7 相同的语言 ....

... Jython 程序目前不能使用用 C 编写的 CPython 扩展模块。这些模块通常具有扩展名为 .so、.pyd 或 .dll 的文件。

如果import _counter, 与文件存在于同一位置,Crypto.Util但作为.so文件存在,这将解释为什么它不会从 Jython 运行。

于 2018-08-03T08:09:01.093 回答