Export to GitHub

py-bcrypt - issue #7

ImportError: No module named _bcrypt


Posted on May 8, 2012 by Happy Panda

What steps will reproduce the problem? 1. python 2. import bcrypt

I'v got this output:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "bcrypt/init.py", line 26, in <module> from _bcrypt import * ImportError: No module named _bcrypt

What version of the product are you using? On what operating system? Ubuntu 11.10 python 2.7

Comment #1

Posted on Jun 2, 2012 by Happy Wombat

Install bcrypt and it will work.

Comment #2

Posted on Jun 11, 2012 by Swift Kangaroo

Try to run 'python' from another location (not where py-bcrypt was unpacked). I had same problem as you, when tried to run from ~/python-install/py-bcrypt-0.2 So I changed to ~ and tried again - everything worked fine :)

Python tries to import bcrypt from source folder (~/python-install/py-bcrypt-0.), it has folder bcrypt with init.py ...

Comment #3

Posted on Nov 24, 2012 by Happy Dog

Had to change "from _bcrypt import *" to "from _bcrypt import hashpw, encode_salt" for this module to work with pypy.

Comment #4

Posted on Jul 28, 2013 by Massive Wombat

This works for me. Are you running python from a directory that has a "bcrypt" subdirectory? That will break things.

Comment #5

Posted on Jul 30, 2013 by Happy Dog

Does this work on Python 3? I'm on Python 3.3.2 and I'm getting the same error message.

Comment #6

Posted on Jul 30, 2013 by Happy Dog

Nevermind, just found this. Would be nice if this was in the main tree.

For my friends coming here from Google like me: https://github.com/wcdolphin/python-bcrypt

Comment #7

Posted on Jul 30, 2013 by Massive Wombat

tip does work from python-3. See https://code.google.com/p/py-bcrypt/wiki/ReleaseNotes_0_4 for the release that's coming in a week or so.

Comment #8

Posted on Jul 31, 2013 by Massive Wombat

wrt comment #3 - I just tried on pypy (stable and tip, non-JIT) and the module (at tip) imported okay but fails. It looks like PyArg_ParseTupleAndKeywords() is broken somehow - it returns success but doesn't actually fill in the string arguments or their respective lengths.

I'll try again with the JIT version of pypy in case that makes any difference; it seems to be what most people use.

Comment #9

Posted on Jul 31, 2013 by Massive Wombat

No change with JIT version. Browsing the pypy code, PyArg_ParseTupleAndKeywords is implemented in ./pypy/module/cpyext/src/getargs.c and "s#" arguments are supported by convertsimple().

I'll file a pypy bug and see what happens.

Comment #10

Posted on Jul 31, 2013 by Massive Wombat

https://bugs.pypy.org/issue1569 filed - it looks like 's#' arg parsing is returning garbage on my pypy

Comment #11

Posted on Jul 9, 2015 by Happy Bear

try apt-get install python2.7-dev

Status: New

Labels:
Type-Defect Priority-Medium