Trouble importing Python library

I’m using python 3.10.0 64 bits, when I try to import ok I get this as a result.

import ok
Traceback (most recent call last):
File “<pyshell#1>”, line 1, in
import ok
File “C:\Users\Slayne\AppData\Local\Programs\Python\Python310\lib\site-packages\ok.py”, line 26, in
_ok = swig_import_helper()
File “C:\Users\Slayne\AppData\Local\Programs\Python\Python310\lib\site-packages\ok.py”, line 22, in swig_import_helper
_mod = imp.load_module(’_ok’, fp, pathname, description)
File “C:\Users\Slayne\AppData\Local\Programs\Python\Python310\lib\imp.py”, line 243, in load_module
return load_dynamic(name, filename, file)
File “C:\Users\Slayne\AppData\Local\Programs\Python\Python310\lib\imp.py”, line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed while importing _ok: %1 is not a valid Win32 application.

I got the ok.py and _ok.pyd files from the 64 bit folder for python 3.6 but I’m not sure what’s wrong and really need some help with this.

It looks like the okFrontPanel.dll file did not get added to the working directory. That file is located in the API/lib folder. More details on using FrontPanel with Python here: Programming Languages - Opal Kelly Documentation Portal

Also, if you are using ok.py and _ok.pyd files from the 64 bit folder for Python 3.6, then you’ll want to ensure that you are using Python 3.6 instead of Python 3.10.0. Using a version of Python outside of the supported version may cause these kinds of warnings/errors.

You can view the supported versions of Python for the latest SDK release at:

Have you ensured that you are using the same 32- or 64-bit version of each component? That includes Python and _ok.pyd, along with any other dependencies you might have.