pythonpycharmpycryptopyjwt

Python - pyJWT Encode Error RS384 Algorithm


Looking for some guidance. I've used pyJWT before and had no issues, but recently moved over to a Mac so I'm wondering if its something with the environment variables I don't know to check. Using Python 3.9, PyCharm and a virtual environment.

Trying to create a JWT, encode it to RS384 algorithm (which is supported according to the documentation at https://pyjwt.readthedocs.io/en/latest/algorithms.html and has worked previously on a Windows Machine).

Created my virtual environment, used PIP3 to install pyJWT and received the error "NotImplementedError: Algorithm 'RS384' could not be found. Do you have cryptography installed?".

I was under the impression that pyJWT would download dependencies but even so I downloaded cyrptography and it still appears to have the issue. I've checked my pip3 list as well as my pyCharm libraries for the virtual environment and everything appears good. Any suggestions on what is going on?

Even the simplest sample code (below) receives this error

Code Sample

import jwt
encoded = jwt.encode({"some": "payload"}, "secret", algorithm="RS384")
print(encoded)

Error Screenshot

PIP3 List

PyCharm Env Setup


Solution

  • Install the PyJWT cryptographic dependencies. Keep in mind that zsh uses square brackets for globbing / pattern matching. That means that if you need to pass literal square brackets as an argument to a command, you either need to escape them or quote the argument like this:

    pip3 install 'pyJWT[crypto]'