Title: ImportError: cannot import name _bcrypt
Type: behaviour Severity: major
Components: Library Versions: Jython 2.7
Milestone: Jython 2.7.0
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: stefan.richthofer Nosy List: Bejgum, stefan.richthofer
Priority: low Keywords:

Created on 2018-05-02.15:26:26 by Bejgum, last changed 2018-05-06.04:35:24 by Bejgum.

msg11936 (view) Author: Robin Sabi Rajan (Bejgum) Date: 2018-05-02.15:26:26
>>> import paramika
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named paramika
>>> import paramiko
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/paramiko/", line 22, in <module>
    from paramiko.transport import SecurityOptions, Transport
  File "/usr/local/lib/python2.7/dist-packages/paramiko/", line 57, in <module>
    from paramiko.ed25519key import Ed25519Key
  File "/usr/local/lib/python2.7/dist-packages/paramiko/", line 17, in <module>
    import bcrypt
  File "/usr/local/lib/python2.7/dist-packages/bcrypt/", line 25, in <module>
    from bcrypt import _bcrypt
ImportError: cannot import name _bcrypt
msg11937 (view) Author: Robin Sabi Rajan (Bejgum) Date: 2018-05-02.15:27:51
Ubuntu 16.04
Python 2.7
  -> Import of paramika from python works fine.
msg11941 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2018-05-02.18:01:08
It looks like bcrypt is mostly written in C.
Jython does not support using C-extensions.
Interestingly, bcrypt states to run with PyPy, so it maybe contains a pure Python fallback, but fails to trigger it for Jython. You could look into the internals and see if a pure Python fallback exists and maybe trigger it manually by a monkeypatch of some flag.

You also might want to try JyNI, see
msg11942 (view) Author: Robin Sabi Rajan (Bejgum) Date: 2018-05-03.03:39:17

I tried bcrypt from pypy, still the same issue. Will look into jyNi as suggested by you.

Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[OpenJDK Server VM (Oracle Corporation)] on java1.8.0_162
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/home/vroadmin/pypy2-v6.0.0-linux32/site-packages')
>>> sys.path.append('/usr/local/lib/python2.7')
>>> sys.path.append('/usr/local/lib/python2.7/dist-packages')
>>> sys.path.append('/usr/lib/python2.7')
>>> sys.path.append('/usr/lib/python2.7/plat-i386-linux-gnu')
>>> sys.path.append('/usr/lib/python2.7/lib-tk')
>>> sys.path.append('/usr/lib/python2.7/lib-old')
>>> sys.path.append('/usr/lib/python2.7/lib-dynload')
>>> sys.path.append('/usr/lib/python2.7/dist-packages')
>>> import bcrypt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vroadmin/pypy2-v6.0.0-linux32/site-packages/bcrypt/", line 24, in <module>
    from bcrypt import _bcrypt
ImportError: cannot import name _bcrypt
msg11947 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2018-05-05.18:47:26
I found time to check bcrypt with JyNI myself by now. Unfortunately it turned out that bcrypt uses cffi, which is not yet supported by JyNI. (E.g. ctypes and cython work rather well...)
I hope we can add that support, but cannot tell when. cffi is actually high on the priority list, but requires buffer protocol support, which is a rather complex enhancement. See for progress on this front.

Setting priority to low and Resolution to "remind", because JyNI is a somewhat separate project and this issue won't fix on Jython's domain. Could normally be a 'won't fix' from Jython perspective, but with remind we can keep track and can test again in future. Feel free to bring up the issue in JyNI's tracker on github.
msg11949 (view) Author: Robin Sabi Rajan (Bejgum) Date: 2018-05-06.04:35:24
Thanks Stefan
Date User Action Args
2018-05-06 04:35:24Bejgumsetmessages: + msg11949
2018-05-05 18:47:27stefan.richthofersetpriority: low
assignee: stefan.richthofer
resolution: remind
messages: + msg11947
2018-05-03 03:39:20Bejgumsetmessages: + msg11942
2018-05-02 18:01:08stefan.richthofersetnosy: + stefan.richthofer
messages: + msg11941
2018-05-02 15:27:51Bejgumsetmessages: + msg11937
2018-05-02 15:26:26Bejgumcreate