What's the easiest way to determine which version of Flask is installed?
15 Answers
As of flask 0.7 (June 28th, 2011), a __version__ attribute can be found on the flask module.
>> import flask
>> flask.__version__
Keep in mind that because prior to flask 0.7 there was no __version__ attribute, the preceding code will result in an attribute error on those older versions.
For versions older than flask 0.7, you might be able to determine it using pkg_resources as shown below:
>>> import pkg_resources
>>> pkg_resources.get_distribution('flask').version
'0.6.1'
This won't work 100% though. It depends on the user having the pkg_resources library installed (it might come by default with a Linux distribution's python installation, but since it's not part of the standard library you can't be positive), and also that the user installed flask in a way that pkg_resources can find it (for example, just copying the full flask source code into your directory puts it out of the range of pkg_resources).
Comments
Via the python interpreter.
>> import flask
>> flask.__version__
'0.7.2'
If flask was installed via pip or easy_install, you can always use the 'pip freeze' command.
2 Comments
flask.__version__ does not work with Flask 0.6.1.flask.__version__ does work. Time marches on.Update on Flask version 1.1.2
- If Flask not installed then go to the required conda environment and write:
$ conda activate "name of conda environment" //py3 in my case
(py3)$ conda install flask
- Post installation check the version with command:
(py3)$ flask --version
Please Note: __version__ is not an attribute of flask anymore for the latest versions and thus flask.__version__ would throw an error
Terminal Output
(py3) xxxxxx@xxxxx:~$ flask --version
Python 3.7.7
Flask 1.1.2
Werkzeug 1.0.1
Comments
just type pip show flask on cmd. You will get all the information about the installed flask. it will show you : name location version and many more
2 Comments
Flask 3.0.0(released on 2023-09-30) deprecated the __version__ attribute and will be removed in Flask 3.1. The recommended way to access the version would be by using importlib.metadata.version API.
>>> import flask
>>> import importlib
>>> flask.__version__
<stdin>:1: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask 3.1. Use feature detection or 'importlib.metadata.version("flask")' instead.
'3.0.0'
>>>
>>> importlib.metadata.version("flask")
'3.0.0'
>>>
Comments
Type flask --version in your interpreter, for example: enter image description here
1 Comment
pip show fastapi uvicorn
Output :
Name: fastapi
Version: 0.75.0
Summary: FastAPI framework, high performance, easy to learn, fast to code, ready for production
Home-page: https://github.com/tiangolo/fastapi
Author: Sebastián Ramírez
Author-email: [email protected]
License: None
Location: /home/mind/Desktop/FASTAPIBasic-/fastenv/lib/python3.8/site-packages
Requires: starlette, pydantic
Required-by:
---
Name: uvicorn
Version: 0.17.6
Summary: The lightning-fast ASGI server.
Home-page: https://www.uvicorn.org/
Author: Tom Christie
Author-email: [email protected]
License: BSD
Location: /home/mind/Desktop/FASTAPIBasic-/fastenv/lib/python3.8/site-packages
Requires: h11, click, asgiref
Required-by: