6
votes

Trying to install py-bcrypt on win7. Python is 64bit. First error unable to find vcvarsall.bat. Googled a bit learned that i needed to install mingw. installed it now this

C:\tools\python_modules\py-bcrypt-0.2>python setup.py build -c mingw32
running build
running build_py
running build_ext
building 'bcrypt._bcrypt' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\Python27\include -Ic:\Python27\PC -c bcrypt/bcrypt_python.c -o b
d\temp.win-amd64-2.7\Release\bcrypt\bcrypt_python.o
bcrypt/bcrypt_python.c:29:26: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c:29:38: error: expected declaration specifiers or '...' before 'u_int16_t'
bcrypt/bcrypt_python.c:29:49: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c: In function 'bcrypt_encode_salt':
bcrypt/bcrypt_python.c:56:2: error: too many arguments to function 'encode_salt'
bcrypt/bcrypt_python.c:29:6: note: declared here
error: command 'gcc' failed with exit status 1

no idea what to do next. guess i'll just not use bcrypt and try something else. Any other suggestions?

7

7 Answers

8
votes

There is a compiled version of py-bcrypt for windows. You can visit https://bitbucket.org/alexandrul/py-bcrypt/downloads to download the .exe file and install.

3
votes

I've looked at the bcrypt source, and can't figure out why you're getting the error you are (don't have a Windows system at hand to test on right now). Though looking at the pybcrypt issue tracker it looks like it has other Windows compilation problems, so it's probably not just you. At a guess though, adding "--std=C99" to the gcc arguments via extra_compile_args might fix at least some of the errors.

Aside from that, there are a couple of alternatives -

  • Bcryptor is another C-extension bcrypt implementation which may compile for your system.

  • Passlib is a general password hashing library. While it relies on bcryptor/pybcrypt for bcrypt support, it has builtin support for a number of other password hashes that may work for you - such as SHA512-Crypt or PBKDF2-HMAC-SHA512

  • Cryptacular is another general password hashing library. On Windows, it provides both BCrypt and PBKDF2-HMAC-SHA512 password hashes. (I'd link straight to those, but the documentation won't quite let me).

3
votes

I stumbled upon this rather old thread while trying to get py-bcrypt installed (via pip) on Windows 7 using VS2012. Apparently, this still doesn't work (I also get the "missing vcvars.bat" error).

There is a dedicated Windows fork for py-bcrypt called py-bcrypt-w32, which I could install without any problems using

pip install py-bcrypt-w32
2
votes

I had the same issue and I fixed it by applying the patch found at this link:

http://code.google.com/p/py-bcrypt/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=1

py-bcrypt_11.patch

Had to apply it manually.

From that thread, the source of the problem is

According to http://groups.google.com/group/mpir-devel/msg/2c2d4cc7ec12adbb (flags defined under the various windows OS'es ,cygwins,mingw's and other's) its better to use _WIN32 instead of _MSC_VER, Together with the change from bzero to memset this compiles both under MSVC and MingW32.

Hope that helps!

0
votes

supposing you are using mingw64, you should change _MSC_VER in _WIN32 on ifdefs into bcrypt.c, bcrypt_python.c and pybc_blf.h

0
votes

I had this same problem with python 3.4.1, and none of the previous answers worked. I eventually got the Visual Studio 2010 64-bit compiler working, and hence both cryptacular and py-bcrypt installed with easy_install. See my detailed answer here: https://stackoverflow.com/a/27033824/3800244

0
votes

It's 2016 and I have faced same issue. Download the wheel directly from https://bitbucket.org/alexandrul/py-bcrypt/downloads and then run following

pip install <whl-file>