11-04-2025 02:40 PM
I am using DIAdem 2025 Q2 with Python 3.12 (installed via miniforge) on Windows 11, and wrote a Python dataplugin to import a specific filetype, using datetime.datetime.strptime to convert a timestamp (my test case is 17Sep25144020 representing 17 September 2025 14:40:20) to a datetime object using "%d%b%y%H%M%S" as the format string. When I test the dataplugin using the same Python installation, I get the expected results. However, when try to use it within DIAdem, I get a log file with the error "PYM: ERROR: Error in python script: attribute of type 'NoneType' is not callable", indicating that strptime exists but isn't method of datetime.
When I remove the strptime conversion, the import works perfectly, albeit without the converted timestamp.
From the autocompletion (below) I can see that there is no datetime.datetime.strptime method available; however, when I check the source location (as shown in the autocompletion tooltip), the strptime method is present in the source file (and is from the same Python installation with which I tested the code).
Can anyone shed some light on why strptime is not working in DIAdem?
Solved! Go to Solution.
11-05-2025 04:40 PM
Have a look at https://operations.systemlink.io/python-dataplugins/python-dataplugins/
There is an open issue with this method.
Use
def strptime(self, value, format):
return datetime.datetime(*(time.strptime(value, "%d.%m.%y %H:%M:%S")[0:6]))
as a workaround.
11-05-2025 05:31 PM
Thanks, I didn't know about that issue with Python, and clearly it has been a problem for some time! That workaround is more concise than the one I devised, so I modified my code and it worked perfectly.