'module' object has no attribute '_strptime' with several threads Python
I can confirm that the issue is related to multithreading, and it happens to me occasionally when I use datetime.datetime.strptime
in combination with the ThreadPool
module.
I was able to fix this in my script by importing the "missing" module as follows:
import _strptime
The problem is described in a mailing list message "threading bug in strptime".
datetime.strptime
has a problem with Python 2's threading
module. The workaround suggested there seems to be to invoke strptime = datetime.datetime.strptime
before any threads are started.
Just ran into this exact problem. It's a tricky one - took me an hour or so to track it down. I tried launching the shell and entering in the following code:
import datetimeprint(datetime.datetime.strptime("2015-4-4", "%Y-%m-%d"))
This worked fine. Then I tried it in a blank file in my workspace. This gave the same error you described. I tried running it from the command line in my workspace. Still gave the error. I then launched the shell from my workspace. This time it gave the error in the shell environment. As it turned out, any directory other than the one I was in worked fine.
The problem was that my project was a python calendar app, and my main file was called "calendar.py". This conflicted with some native import, thus creating the bizarre error.
In your case, I'd bet anything the problem is the name of your file: "file.py". Call it something else, and you should be good to go.