11

I have been trying to run this project https://github.com/udacity/FSND-Deploy-Flask-App-to-Kubernetes-Using-EKS

I installed all the dependencies. I still did not make any adjustments. I need to run it first but I get this error when I type the command

python main.py

this is the error i get:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    import jwt
ImportError: No module named jwt

I worked with similar errors before and managed to solve them but not with this one I could not figure out the source of the problem

Sayed Sohan
  • 1,385
  • 16
  • 23
Rawan J9
  • 111
  • 1
  • 1
  • 3

7 Answers7

17
  1. Check if PyJWTY is in the requirements file or if is installed in you system, using: pip3 install PyJWT
  2. You could also face this error if you have running on your machine two versions of python. So the correct command will be python3 main.py
5

I have hit the same issue with pyjwt 2.1.0 which was clearly installed in my venv as well as globally. What helped was to downgrade it to version 1.7.1

pip install "PyJWT==1.7.1"

run the app and then to reinstall newest version 2.1.0

pip install "PyJWT==2.1.0"

And the issue disappeared.

Filip
  • 181
  • 2
  • 7
2

This project has requirements that need to be installed for it to work. These can be installed via pip, pip install -r requirements.txt (I've linked to the requirements file in the project), which you can read more about here.

pgjones
  • 6,044
  • 1
  • 14
  • 12
  • hello thanks for answering i did install the requirements and checked that jwt is installed but still getting the same error – Rawan J9 Aug 08 '20 at 22:09
2

What worked for me was using import jwt instead of import PyJWT. I am using version PyJWT-2.3.0.

jwt image on vscode As you can see no errors in the above screenshot. The app runs without import errors. Image of terminal

Prateek p
  • 117
  • 1
  • 11
0

Faced the same issue. Am using a guest VM running ubuntu 16.04. I have multiple versions of python installed - both 3.5 and 3.7.

After repeated tries with and without using virtualenv what worked finally is:

  1. Create a fresh virtual environment using :
    priya:~$ virtualenv -p /usr/bin/python3.7 fenv

  2. Activate the virutal environment : priya:~$ source ./fenv/bin/activate

Note : You can find the path for python3.7 by using whereis python: priya:~$ whereis python python: /usr/bin/python /usr/bin/python3.5m /usr/bin/python3.5 /usr/bin/python3.7 /usr/bin/python3.5m-config /usr/bin/python3.5-config /usr/bin/python2.7 /usr/bin/python3.7m /usr/bin/python2.7-config /usr/lib/python3.5 /usr/lib/python3.7 /usr/lib/python2.7 /etc/python /etc/python3.5 /etc/python3.7 /etc/python2.7 /usr/local/lib/python3.5 /usr/local/lib/python3.7 /usr/local/lib/python2.7 /usr/include/python3.5m /usr/include/python3.5 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz

Referenced link is : https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv#:~:text=By%20default%2C%20that%20will%20be,%2Flocal%2Fbin%2Fpython3

For your project - FSWD Nanodegree - After you have activated your virtualenv, run pip install -r requirements.txt You can test by : (fenv) priya:FSND-Deploy-Flask-App-to-Kubernetes-Using-EKS :~$ python Python 3.7.9 (default, Aug 18 2020, 06:24:24) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

import jwt exit()

0

pip3 install flask_jwt_ex.. I was doing this without sudo. And then I was working on the program as sudo.

Rifat Dinc
  • 19
  • 1
  • 5
0

You have to have only PyJWT installed and not JWT. Make sure you uninstall JWT (pip uninstall JWT) and install PyJWT (pip install PyJWT)

Amir nazary
  • 384
  • 1
  • 7