Gihan Gamage
Gihan Gamage

Reputation: 3354

Invalid Syntax jose.py

I was trying to use jose library for authentication for one of my flask apps. using the import statement as follows

from jose import jwt

But it throws following An error,

Traceback (most recent call last):
   File "F:/XXX_XXX/xxxx-services-web/src/auth.py", line 6, in <module>
      from jose import jwt
   File "F:\Users\XXXX_XXXXX\AppData\Local\Programs\Python\Python37\lib\site-packages\jose.py", line 546
      print decrypt(deserialize_compact(jwt), {'k':key},
            ^
SyntaxError: invalid syntax

Is this library outdated?

Upvotes: 22

Views: 13610

Answers (2)

Amir nazary
Amir nazary

Reputation: 695

Install python-jose instead of installing jose.

You can also use import python_jwt as jwt instead of from jose import jwt and install the package via pip install python-jwt

Upvotes: 6

Gihan Gamage
Gihan Gamage

Reputation: 3354

installing python-jose instead of jose fixed my problem. https://pypi.org/project/python-jose/

Upvotes: 44

Related Questions