Conflict between PyQt5 and datetime.datetime.strptime
<p>So I was writing a tool that would read time from file using graphical user interface based on python 3.52 and Qt5. The minimal operation</p>

<pre><code>datetime.datetime.strptime('Tue', '%a')
</code></pre>

<p>works in an isolated environment, giving output "1900-01-01 00:00:00". However, when I run the following minimal example</p>

<pre><code>import sys
import datetime as datetime

from PyQt5 import QtWidgets

if __name__ == '__main__' :
    print(datetime.datetime.strptime('Tue', '%a'))
    app = QtWidgets.QApplication(sys.argv)
    print(datetime.datetime.strptime('Tue', '%a'))
    #sys.exit(app.exec_())
</code></pre>

<p>I get the output</p>

<pre><code>1900-01-01 00:00:00
Traceback (most recent call last):
File "/home/user/gui/testfile.py", line 11, in &lt;module&gt;
print(datetime.datetime.strptime('Tue', '%a'))
File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime
(data_string, format))
ValueError: time data 'Tue' does not match format '%a'
</code></pre>

<p>So, the first call to the <i>strptime</i> routine works fine, but after the <i>QApplication</i> class is created, it does not work any more. Note that further using <i>QApplication</i> to construct the GUI and do a lot of complicated things with it works fine. The only thing that does not work currently is <i>strptime</i></p>

<p>Any idea what goes wrong?</p>

<p>To elaborate on the nice answer by Patrick, I have now found a way to undo the localization enforced by QT</p>

<pre><code>import sys
import datetime as datetime
import locale

from PyQt5 import QtWidgets

## Start the QT window
print(datetime.datetime.strptime('Tue', '%a'))
app = QtWidgets.QApplication(sys.argv)
locale.setlocale(locale.LC_TIME, "en_GB.utf8")
print(datetime.datetime.strptime('Tue', '%a'))
#sys.exit(app.exec_())
</code></pre>

python datetime pyqt5