'How to resolve versionConflict error in Flask (PyJWT and Flask-JWT-Extended)
I want to run a very simple application using Flask framework. I have also run and developed flask app before. After a while I need to develop a new simple app using it.
So I have created a virtual environment and activated it:
virtualenv venv
source venv/bin/activate
python --version # prints 3.8.6
pip --version # prints pip 20.3.1
Then installed Flask:
(venv) pip install -U Flask
Here is my hello world code:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World!"
Whenever I run flask run command I face to the following error:
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (PyJWT 2.0.0 (/home/user/.local/lib/python3.8/site-packages), Requirement.parse('PyJWT<2.0,>=1.6.4'), {'Flask-JWT-Extended'})
I have also seen the similar links which I refer them below but I didn't get any clue about how resolving it.
P.S It is notable that I have tried installing different version of PyJWT like 1.7.1, 2.0.0, etc. but none of them worked properly.
Solution 1:[1]
Make sure to pip install --upgrade flask-jwt-extended as well. The newest version of that should work fine with flask 2.x.x and PyJWT 2.x.x.
Versions:
Flask==2.0.1
PyJWT==2.1.0
Flask_JWT_Extended==4.2.1
For more details you can checkout the following links: link1 | link2
Solution 2:[2]
This solved my issue without having to make a new Venv/Environment from scratch :
try uninstalling Flask and all Flask Related modules and then just run
pip install flask-jwt-extended which will install flask properly again.
works with flask-jwt-extended==4.3.1 and will setup flask==2.0.2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mostafa Ghadimi |
| Solution 2 | ckloan |
