Reputation: 461167
What's the easiest way to determine which version of Flask is installed?
Upvotes: 81
Views: 118108
Reputation: 24582
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'
>>>
Upvotes: 0
Reputation: 11
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
Upvotes: 1
Reputation: 47
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:
Upvotes: -1
Reputation: 1
Type flask --version
in your interpreter, for example: enter image description here
Upvotes: -1
Reputation: 115
Update on Flask version 1.1.2
$ conda activate "name of conda environment" //py3 in my case
(py3)$ conda install flask
(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
Upvotes: 2
Reputation: 1
Just type:
python -m flask --version
Output:
Python 3.7.2
Flask 1.1.1
Werkzeug 0.16.0
Upvotes: -1
Reputation: 788
If managing with pip can just use list command to see all the packages and versions
pip list
Upvotes: 2
Reputation:
It's quite simple !
In your terminal:
pip freeze | grep Flask
The output should be something like this:
Output: Flask==0.12
Upvotes: 14
Reputation: 2201
If someone is trying to determine flask version via Anaconda Command Prompt then just run the following command:
flask --version
Above command will give following output format:
Python 3.7.3
Flask 1.1.1
Werkzeug 0.15.4
Upvotes: 8
Reputation: 101
>>> import flask
>>> flask.__version__ #(To find the version)
'1.0.2'
>>> print flask.__file__ #(To find out the path where it is installed)
/usr/local/rnt/lib/python2.7/site-packages/flask/__init__.pyc
Upvotes: 3
Reputation: 19733
using dpkg:
dpkg -l | grep flask
output:
ii python-flask 0.8-1 all micro web framework based on Werkzeug, Jinja2 and good intentions
Upvotes: 3
Reputation: 9301
More general way of doing it is :
pip freeze
It will list all installed python packages and their versions. If you want to see just flask then try :
pip freeze | grep flask
Upvotes: 24
Reputation: 43071
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).
Upvotes: 100
Reputation: 1099
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.
Upvotes: 21