2

Trying to get bcrypt working on windows has been a challenge. I finally found a reddit thread pointing to a windows distribution of bcrypt (http://www.reddit.com/r/flask/comments/15q5xj/anyone_have_a_working_version_of_flaskbcrypt_for/), and it finally installed, see below!

C:\pyprojects\flask-security>flask\scripts\pip list
blinker (1.3)
chardet (2.2.1)
decorator (3.4.0)
Flask (0.9)
Flask-Login (0.2.10)
Flask-Mail (0.7.6)
Flask-Principal (0.4.0)
Flask-Security (1.7.3)
Flask-SQLAlchemy (0.16)
Flask-WhooshAlchemy (0.55a)
Flask-WTF (0.8.4)
itsdangerous (0.24)
Jinja2 (2.7.2)
lamson (1.3.4)
MarkupSafe (0.19)
passlib (1.6.2)
pip (1.5.4)
py-bcrypt (0.4)
pywin32 (219)
setuptools (0.6c11)
SQLAlchemy (0.7.9)
sqlalchemy-migrate (0.7.2)
Tempita (0.5.2)
Werkzeug (0.9.4)
Whoosh (2.6.0)
WTForms (1.0.5)

However, when trying to use it with passlib I'm still getting the following error:

passlib.exc.MissingBackendError
MissingBackendError: no bcrypt backends available - please install py-bcrypt

here's the full trace:

File "C:\pyprojects\flask-security\flask\lib\site-packages\flask\app.py", line 1701, in __call__
return self.wsgi_app(environ, start_response)
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask\app.py", line 1689, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask\app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask\app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask\app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask\app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask_security\decorators.py", line 205, in wrapper
return f(*args, **kwargs)
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask_security\views.py", line 117, in register
user = register_user(**form.to_dict())
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask_security\registerable.py", line 28, in register_user
kwargs['password'] = encrypt_password(kwargs['password'])
File "C:\pyprojects\flask-security\flask\lib\site-packages\flask_security\utils.py", line 151, in encrypt_password
return _pwd_context.encrypt(signed)
File "C:\pyprojects\flask-security\flask\lib\site-packages\passlib\context.py", line 2495, in encrypt
return self._get_record(scheme, category).encrypt(secret, **kwds)
File "C:\pyprojects\flask-security\flask\lib\site-packages\passlib\utils\handlers.py", line 558, in encrypt
self.checksum = self._calc_checksum(secret)
File "C:\pyprojects\flask-security\flask\lib\site-packages\passlib\handlers\bcrypt.py", line 285, in _calc_checksum
return self._calc_checksum_backend(secret)
File "C:\pyprojects\flask-security\flask\lib\site-packages\passlib\utils\handlers.py", line 1454, in _calc_checksum_backend
self.set_backend()
File "C:\pyprojects\flask-security\flask\lib\site-packages\passlib\utils\handlers.py", line 1442, in set_backend
raise exc.MissingBackendError(cls._no_backends_msg())
MissingBackendError: no bcrypt backends available - please install py-bcrypt

Anyone have a clue what I'm missing?

4

1 回答 1

1

Found what was going on. I had been using the virtualenv instruction the Mega Flask Tutorial. Though when I'd go to start a new project, I just copied the folder to a new location, renamed it, and proceeded on my merry way. Turns out that pip was still installing things to one of my older projects, which I stumbled upon by accident by doing:

pip show py-bcrypt

Which showed the path to one of my old projects.

Once I told pip to install the wheel file directly to the project I wanted it in, everything worked great. See below:

pip install py_bcrypt-0.4-cp27-none-win32.whl -t c:\path\to-desired-project\flask\lib\site-packages

Now if only I could figure out how to permanently change the pip install directory... lol

于 2014-09-23T16:17:16.130 回答