How to get time.strptime()?

Nick Cash at
Wed Dec 26 22:06:12 CET 2012

> Error: AttributeError: 'module' object has no attribute '_strptime'
> This problem is driving me crazy. It only happens in Python 3.3.0,
> while on my server running 3.1.3 it behaves as expected. When I try to
> access time.strptime() it errors with
> AttributeError: 'module' object has no attribute '_strptime'.
> This error only occurs under mod_wsgi, when running as a one-shot
> webapp it behaves normally. All other functionalities of the time
> module are normal.

I've run into this issue in the past with Python 2.6 (or maybe 2.7) and mod_python. My problem was that datetime.strptime imported _strptime at runtime, and multiple threads trying to import it at the same time broke an internal import lock.

I was able to work around this by simply importing _strptime myself at server startup time. This may or may not work for you.

See also: and 

More information about the Python-list mailing list