Reputation: 221
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
Upvotes: 22
Views: 96381
Reputation: 1
Install: pip install python-jose
Import: from jose import JWTError, jwt
Upvotes: 0
Reputation: 12021
I had this trouble on MacOS and the provided solutions don't work for me because of this error:
× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the package you are trying to
install.
If you wish to install a Python library that isn't in Homebrew,
use a virtual environment:
python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install xyz
...
So I had to install venv
in order to run my script. I'm not a python guy, so it was quite challenging at first time. Here's help for people like me:
venv
folder: python3 -m venv ./venv
venv
: source venv/bin/activate
pip install PyJWT
Note, that while you are in venv
, don't need to call python3
or pip3
, since python3
was already activated on step 1.python script.py
deactivate
Upvotes: 3
Reputation: 715
You have to have only PyJWT
installed and not JWT
. Make sure you uninstall JWT
(pip uninstall JWT
) and install PyJWT
(pip install PyJWT
)
Upvotes: 2
Reputation: 135
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
Upvotes: 4
Reputation: 301
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.
Upvotes: 7
Reputation: 39
pip3 install flask_jwt_ex.. I was doing this without sudo. And then I was working on the program as sudo.
Upvotes: 0
Reputation: 39
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:
Create a fresh virtual environment using :
priya:~$ virtualenv -p /usr/bin/python3.7 fenv
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()
Upvotes: 0
Reputation: 406
Upvotes: 27
Reputation: 7049
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.
Upvotes: 2