What’s the easiest way to determine which version of Flask is installed?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As of flask 0.7 (June 28th, 2011), a
__version__attribute can be found on the flask module.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:
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).