Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting package version using pkg_resources?

Tags:

What is the recommended way getting hold of the package version of a package in the $PYTHONPATH or sys.path?

I remember that the pkg_resource module has some functionality for this but I can not find any related information. Please don't point me to solution using a version.py file and reading it somehow. Using pkg_resources is the way to go but how exactly?

like image 466
Andreas Jung Avatar asked Jan 16 '12 13:01

Andreas Jung


People also ask

What does Pkg_resources do?

pkg_resources is a module used to find and manage Python package/version dependencies and access bundled files and resources, including those inside of zipped . egg files.

What is Pkg resources Python?

The pkg_resources module distributed with setuptools provides an API for Python libraries to access their resource files, and for extensible applications and frameworks to automatically discover plugins.


1 Answers

>>> import pkg_resources >>> pkg_resources.get_distribution("PIL").version '1.1.7' 
like image 191
AdamKG Avatar answered Oct 10 '22 00:10

AdamKG