1

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

asked Jun 22, 2022 at 18:50
2
  • 1
    even if you follow the answer below and get all dependencies sorted, the next error will be about your key. You can't just use a simple string, as you might have used before for HS256, as a key for ES384. You need a real ES384 private key instead. Commented Jun 22, 2022 at 19:09
  • Thanks for the info. I was previously using a .pem file I was reading in my Windows project. I was just trying to make it the simplest example possible to rule out other issues, but will note that. Thank you. Commented Jun 22, 2022 at 20:47

1 Answer 1

0

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]'
answered Jun 22, 2022 at 18:55
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the suggestion. Two comments: 1) I had tried that earlier per a google search and when I attempt to run that in my terminal I get the following error "zsh: no matches found: pyjwt[crypto]" even though running pip works fine. Side note i'm also using pip3 but I think it should be the same. 2) I was under the impression that pip would install all dependencies, is this not accurate?
The fix to my above issue is as follows. I found out 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]' rather than pip3 install pyJWT[crypto]
Good job! I was going to suggest that you look into zsh as I installed them succesfully with Bash, but you got it. I've edited the answer, could you accept it? Glad you got it sorted! Good luck with the project.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.