我尝试通过werkzeug中的generate_password_hash生成密码哈希。但它似乎不起作用。
>>> from werkzeug.security import generate_password_hash
>>> generate_password_hash('foobar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/l0o0/Workspace/flask/env/lib/python2.7/site-packages/werkzeug/security.py", line 230, in generate_password_hash
h, actual_method = _hash_internal(method, salt, password)
File "/home/l0o0/Workspace/flask/env/lib/python2.7/site-packages/werkzeug/security.py", line 192, in _hash_internal
hashfunc=hash_func)
File "/home/l0o0/Workspace/flask/env/lib/python2.7/site-packages/werkzeug/security.py", line 65, in pbkdf2_hex
return to_native(codecs.encode(rv, 'hex_codec'))
File "/home/l0o0/Workspace/flask/env/lib/python2.7/encodings/__init__.py", line 120, in search_function
entry = getregentry()
File "/home/l0o0/Workspace/flask/env/lib/python2.7/encodings/hex_codec.py", line 79, in getregentry
_is_text_encoding=False,
TypeError: __new__() got an unexpected keyword argument '_is_text_encoding'
werkzeug版本是Werkzeug-0.11.11并由pip安装。 希望有人可以提供帮助。
补充:我hava尝试在另一台服务器上使用相同的命令,似乎没问题。
我通过sudo apt-get install python-werkzeug
安装此模块,没有virtualenv,它工作正常。