2

I 'm using Jython to execute a python script connect_host.py which uses paramiko module to connect to a specified host.

paramiko module internally uses Crypto module, and Crypto.Util module uses Counter.py which in turn tries to import _counter,which is present in the same location Crypto.Util but as an .so file .

On execution, python throws the following error:

 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

How to make Jython load _counter module,which is a .so file??????

  • I'm not at all experienced with Jython, so I have to ask: Is there any reason to expect an `.so` file to be usable with it? That's probably a C shared library for use with CPython. I'd be more surprised it if worked than if it didn't. – Blckknght Apr 24 '15 at 07:15
  • You said, "python throws the error" but you're asking about Jython. Which is it? – Stewart Aug 03 '18 at 06:42

1 Answers1

0

In this Python documentation it says:

Jython is an implementation of the Python language for the Java platform. Jython 2.7 implements the same language as CPython 2.7 ....

... Jython programs cannot currently use CPython extension modules written in C. These modules usually have files with the extension .so, .pyd or .dll.

If import _counter, is present in the same location as Crypto.Util but as an .so file, this would explain why it won't run from Jython.

Community
  • 1
  • 1
Stewart
  • 17,616
  • 8
  • 52
  • 80