Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the version of the datetime module in python?

Tags:

python

I know that this question was asked million of time regarding other libraries. However none of the answers in other discussions was helpful.

I tried:

import datetime
print datetime.version

import datetime
print datetime._version_

import datetime
print datetime.__version__

None is working.

It says

attribute error: AttributeError: 'module' object has no attribute 'version'

Same for the others.

This library do have versions: https://pypi.python.org/pypi/DateTime

like image 941
avi Avatar asked Jan 18 '17 07:01

avi


2 Answers

datetime is different with DateTime. datetime is the native Python library, while your link is a third party library. Try using pkg_resources

import pkg_resources
pkg_resources.get_distribution("DateTime").version
like image 80
Edwin Lunando Avatar answered Sep 29 '22 01:09

Edwin Lunando


As datetime is a build-in package, it correspondences with your Python installation. https://docs.python.org/2/library/datetime.html

The DateTime module you provided is not the same.

like image 24
ppasler Avatar answered Sep 29 '22 02:09

ppasler