"OSError: [WinError 193] %1 is not a valid Win32 application" for a dll library
13:02 30 Jun 2026

I'm trying to run this code to connect to a numerical picoscope, and then run a bigger code :

import os
import platform
import ctypes

dll_dir = "C:\Program Files (x86)\Pico Technology\PicoScope6"
dll_name = "PS2000a.dll"

os.add_dll_directory(dll_dir)

dll_path = os.path.join(dll_dir, dll_name)

lib = ctypes.WinDLL(dll_path)
print("Loaded")

But I get this error :

%runfile '//katmandou/Share/530-Composants_Optiques_Multimédias/530.5-capteurs_optiques/530.5.2-caracterisation/Carac_QCLs_WaferLevel/programs/python_libraries/lco_laser_characterization/test_lib_import.py' --wdir
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
File \\katmandou\share\530-composants_optiques_multimédias\530.5-capteurs_optiques\530.5.2-caracterisation\carac_qcls_waferlevel\programs\python_libraries\lco_laser_characterization\test_lib_import.py:19
     15 os.add_dll_directory(dll_dir)
     17 dll_path = os.path.join(dll_dir, dll_name)
---> 19 lib = ctypes.WinDLL(dll_path)
     20 print("Loaded")

File ~\.conda\envs\qcl_env\Lib\ctypes\__init__.py:379, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    376 self._FuncPtr = _FuncPtr
    378 if handle is None:
--> 379     self._handle = _dlopen(self._name, mode)
    380 else:
    381     self._handle = handle

OSError: [WinError 193] %1 is not a valid Win32 application

I'm running this code on a 64 bits computer, the picoscope software is also a 64 bits one. So I don't understand.

I tried to run this code in a virtual environnment. This virtual environment was identical to the one used in an other computer where this code runs without any problem. But I still have this issue.

What's the problem ? What can I do to solve this issue ?

python dll bit