在Windows上为python和passlib安装了bcrypt - 仍然有MissingBackendError

时间:2014-09-22 23:04:54

标签: python windows flask bcrypt flask-security

试图让bcrypt在Windows上工作一直是一个挑战。我终于找到了一个指向bcrypt(http://www.reddit.com/r/flask/comments/15q5xj/anyone_have_a_working_version_of_flaskbcrypt_for/)的windows发行版的reddit线程,最后安装了,见下文!

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)

但是,当尝试将它与passlib一起使用时,我仍然会收到以下错误:

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

这是完整的痕迹:

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

任何人都知道我缺少什么?

1 个答案:

答案 0 :(得分:0)

发现了什么。我一直在使用virtualenv指令Mega Flask Tutorial。虽然当我开始一个新项目时,我只是将文件夹复制到一个新位置,重命名它,然后继续我的快乐方式。事实证明,pip仍在为我的一个旧项目安装东西,我偶然发现了这样做:

pip show py-bcrypt

这显示了我的一个旧项目的路径。

一旦我告诉pip将wheel文件直接安装到我想要的项目中,一切都很顺利。见下文:

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

现在,如果我能弄明白如何永久更改pip安装目录... lol