Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining what version of Flask is installed

Tags:

python

flask

What's the easiest way to determine which version of Flask is installed?

like image 259
Matthew Rankin Avatar asked Mar 12 '11 22:03

Matthew Rankin


People also ask

What is the latest Flask version?

Flask is the most used framework for web development according to the Jetbrains Python Developers Survey from 2020, and in May of 2021, version 2.0.

Is Flask installed with Python?

Flask is installed automatically with all the dependencies. Note: pip is a Python package manager. To install pip follow one of our guides: How to install pip on CentOS 7, How to install pip on CentOS 8, How to install pip on Debian, or How to install pip on Ubuntu.


2 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).

like image 198
Mark Hildreth Avatar answered Oct 13 '22 21:10

Mark Hildreth


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 
like image 24
Saša Šijak Avatar answered Oct 13 '22 23:10

Saša Šijak