Mostafa Ghadimi
Mostafa Ghadimi

Reputation: 6786

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.

link1 | link2 | link3

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.

Upvotes: 2

Views: 5183

Answers (3)

Christian Kasim Loan
Christian Kasim Loan

Reputation: 422

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

Upvotes: 0

vimalloc
vimalloc

Reputation: 4187

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

Upvotes: 2

Mostafa Ghadimi
Mostafa Ghadimi

Reputation: 6786

It seems that the newest version of Flask (currently 2.0.1) has problem with dependencies.

The problem was resolved after downgrading it to 1.1.2 via the following command:

pip install Flask==1.1.2

Hope it will be fixed in near future!

Upvotes: 0

Related Questions