Dash tutoriel error : Unexpected keyword argument - python

i'm learning Dash following this tutoriel https://github.com/amyoshino/Dash_Tutorial_Series
the problem is that when i install the project and try to run app.py function i found this error :
Traceback (most recent call last):
File "app.py", line 58, in <module>
dcc.Checklist(
File
"C:\Users\Asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\
LocalCache\local-packages\Python38\site-packages\dash\development\base_component.py",
line 42, in wrapper
return func(*args, **kwargs)
File
"C:\Users\Asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\
local-packages\Python38\site-packages\dash_core_components\Checklist.py", line 69, in __init__
super(Checklist, self).__init__(**args)
File
"C:\Users\Asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\
LocalCache\local-packages\Python38\site-packages\dash\development\base_component.py", line 82, in
__init__
raise TypeError(
TypeError: Unexpected keyword argument `values`
Allowed arguments: className, id, inputClassName, inputStyle, labelClassName, labelStyle,
loading_state, options, persisted_props, persistence, persistence_type, style, value
PS: I have installed all the requirements and libraries needed
when i change values with value the code runs but when i open the localhost another error occur
127.0.0.1 - - [17/Jan/2021 15:53:20] "←[35m←[1mGET /_dash-component-
suites/dash_renderer/dash_renderer.min.js.map?v=1.8.3 HTTP/1.1←[0m" 500 -
Traceback (most recent call last):
File
"C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File
"C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File
"C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1867, in
handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1952, in
full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1821, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1950, in
full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1936, in
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File
"C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\
dash\dash.py", line 393, in serve_component_suites
mimetype = ({
KeyError: 'map'
127.0.0.1 - - [17/Jan/2021 15:53:21] "←[35m←[1mGET /_dash-component-
suites/dash_renderer/dash_renderer.min.js.map?v=1.8.3
HTTP/1.1←[0m" 500 -
Traceback (most recent call last):
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\Asus\AppData\Local\
Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1867, in
handle_exception
reraise(exc_type, exc_value, tb)
File
"C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\Asus\AppData\Local\
Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1952, in
full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1821, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1950, in
full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\flask\app.py", line 1936, in
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\Asus\AppData\Local\Packages\
PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-
packages\Python38\site-packages\dash\dash.py", line 393, in
serve_component_suites
mimetype = ({
KeyError: 'map'
127.0.0.1 - - [17/Jan/2021 15:53:21] "←[37mGET /favicon.ico HTTP/1.1←[0m" 200 -

That repo contains the error. As the traceback informs you, values is not allowed there, but you can use value. Change it locally and it should resolve the error. Additionally, you could make a pull request to that repo and help the original author(s) by fixing a bug in their code.

Related

AttributeError: 'CollectionReference' object has no attribute 'stream'

I am looking at reading information from firestore. So I followed the examples from here. Here is my code. It's a Flask application which calls the firestore client.
#menuapi_routes.route("/api/menu")
def get_menus():
menu_items = get_menu_items()
retval = []
for item in menu_items.stream():
retval.append(u' {} => {}'.format(item.id, item.to_dict()))
return json.dumps(retval)
The code which is getting called is.
def get_menu_items():
db = firestore.Client()
doc_ref = db.collection(u'menus')
return doc_ref
The error I get is
127.0.0.1 - - [16/May/2020 22:09:24] "GET / HTTP/1.1" 404 -
[2020-05-16 22:09:34,236] ERROR in app: Exception on /api/menu [GET]
Traceback (most recent call last):
File "\venv\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "\venv\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "\venv\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "\venv\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "\venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "\app\api\menu\menu.py", line 13, in get_menus
for item in menu_items.stream():
AttributeError: 'CollectionReference' object has no attribute 'stream'
Exception on /api/menu [GET]
Traceback (most recent call last):
File "\venv\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "\venv\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "\venv\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "\venv\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "\venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "\app\api\menu\menu.py", line 13, in get_menus
for item in menu_items.stream():
AttributeError: 'CollectionReference' object has no attribute 'stream'
Exception on /api/menu [GET]
Traceback (most recent call last):
File "\venv\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "\venv\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "\venv\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "\venv\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "\venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "\app\api\menu\menu.py", line 13, in get_menus
for item in menu_items.stream():
AttributeError: 'CollectionReference' object has no attribute 'stream'
127.0.0.1 - - [16/May/2020 22:09:34] "GET /api/menu HTTP/1.1" 500 -

Request Bitbucket API with an access token

I'm trying to call Bitbucket API in my python script to retrieve some data.
I use the key/secret pair of Bitbucket OAuth.
data = { 'grant_type': 'client_credentials'}
response = requests.post('https://bitbucket.org/site/oauth2/access_token', data=data, auth=(key, secret))
print(response.json())
access_token = response.json()['access_token']
print(access_token)
groups = requests.get("https://api.bitbucket.org/1.0/groups/myaccount/", headers={"Bearer %s" %access_token})
print(groups.json())
This gives me an error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/vagrant/projects/tools/axb-dsi-api/app/bitbucket_connector.py", line 35, in get_groups
groups = requests.get("https://api.bitbucket.org/1.0/groups/myaccount/", headers={"Bearer %s" %access_token})
File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 494, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 437, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 306, in prepare
self.prepare_headers(headers)
File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 438, in prepare_headers
for header in headers.items():
AttributeError: 'set' object has no attribute 'items'
How do we use access token to call BitBucket API REST ?
EDIT
After correcting the header to json :
now it's saying
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/vagrant/projects/tools/axb-dsi-api/app/bitbucket_connector.py", line 36, in get_groups
print(groups.json())
File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
the headers parameter to the requests.get() should be an dictionary and you are sending set instead of the dictionary check your code it is headers={"Bearer %s" %access_token} which treated as set you can execute this on python and check.
You may need to use key:value check below example:
groups = requests.get("https://api.bitbucket.org/1.0/groups/myaccount/", headers={'access_token' : "Bearer %s" %access_token})
I successfuly get to retreive the data from Bitbucket API by passing the access token this way:
groups = requests.get("https://api.bitbucket.org/1.0/groups/myaccount/access_token={%s}"%access_token)
Use Authorization as a key in the header instead of access_token try below code.
groups = requests.get("https://api.bitbucket.org/1.0/groups/myaccount/", headers={'Authorization' : "Bearer %s" %access_token})

Flask doesn't see the static file

Regards, It's been seeing my static files by now. I am using VS Code as an editor. I clicked accidentally debug mode and then it stopped seeing my static files. I started VS Code again but the result hasn't changed. How can I solve this problem? When I open localhost, it shows 127.0.0.1:5000/static/css/main.css but it gives an error when I display the page source and open the css file on the new page.
The error I get in the browser is: TypeError: make_conditional() got an unexpected keyword argument 'accept_ranges'
The error I received in VS Code is as follows:
127.0.0.1 - - [12/Dec/2018 23:17:50] "GET /static/css/main.css HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.6/site-packages/flask/helpers.py", line 976, in send_static_file
cache_timeout=cache_timeout)
File "/usr/local/lib/python3.6/site-packages/flask/helpers.py", line 713, in send_from_directory
return send_file(filename, **options)
File "/usr/local/lib/python3.6/site-packages/flask/helpers.py", line 628, in send_file
complete_length=fsize)
TypeError: make_conditional() got an unexpected keyword argument 'accept_ranges'
According to flask, the required Werkzeug version is Werkzeug >= 0.14 from here

KeyError: 'oauth_state'

Hi I am currently trying to test the code on https://github.com/futurice/whereareyou
I have a problem on the master server side.
The error received
Traceback (most recent call last):
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1997, in call
return self.wsgi_app(environ, start_response)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/home/arms/.local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/arms/Project/whereareyou/app.py", line 112, in callback
google = get_google_auth(state=session['oauth_state'])
File "/home/arms/.local/lib/python2.7/site-packages/werkzeug/local.py", line 377, in
getitem = lambda x, i: x._get_current_object()[i]
KeyError: 'oauth_state'
Please help. Thank you.
I was facing the same problem when I was using session in my app with the following link provided by Flask :
http://127.0.0.1:5000/
Solution: It however perfectly works with http://localhost:5000/
Just replace your local IP address(127.0.0.1) with "localhost".

"TypeError: hashpw() argument 1 must be str, not bytes" when trying to register a user with flask-security

I'm trying to create a small flask application using the Enferno framework, but when I try to register a user I get an error that seems to be generated by the passlib library. I can't understand if it's something I did or if it is an error in the library itself.
Here's the full traceback:
Traceback (most recent call last):
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
return view_func(**req.view_args)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/decorators.py", line 205, in wrapper
return f(*args, **kwargs)
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/views.py", line 117, in register
user = register_user(**form.to_dict())
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/registerable.py", line 28, in register_user
kwargs['password'] = encrypt_password(kwargs['password'])
File "/home/el3k0n/.local/lib/python3.4/site-packages/flask_security/utils.py", line 151, in encrypt_password
return _pwd_context.encrypt(signed)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/context.py", line 2495, in encrypt
return self._get_record(scheme, category).encrypt(secret, **kwds)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/utils/handlers.py", line 558, in encrypt
self.checksum = self._calc_checksum(secret)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/handlers/bcrypt.py", line 285, in _calc_checksum
return self._calc_checksum_backend(secret)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/utils/handlers.py", line 1458, in _calc_checksum_backend
return self._calc_checksum_backend(secret)
File "/home/el3k0n/.local/lib/python3.4/site-packages/passlib/handlers/bcrypt.py", line 333, in _calc_checksum_pybcrypt
hash = _bcrypt.hashpw(secret, config)
TypeError: hashpw() argument 1 must be str, not bytes
I just ran into this. Turns out, I had installed both bcrypt and python-bcrypt in my virtualenv. passlib.hash.bcrypt has a check to see which version on bcrypt is present. By removing the python-bcrypt, I was able to cease this error from being thrown.

Categories

Resources