Python Forum
[WinError 193] %1 is not a valid Win32 application
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WinError 193] %1 is not a valid Win32 application
#1
I am trying to invoke the SQLITE3 API to backup a database. I found a sample script which does this and I was testing it.

Some searches pointed me to a 'fix' with the find_library part of the code, that I should replace it with the full path to the DLL. I did that. That is when I started to get the subject error. Searching on the error pointed me to this forum, but not to a resolution.

I'm in Win10; Python 3.6.3/64 and I am trying this with SQLite3 3.22.0.0/64 DLL I just downloaded.
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32

#! /usr/bin/env python
# Of course, the author does not guarantee safety.
# I did my best by using SQLite's online backup API.
from __future__ import print_function
import sys, ctypes
from ctypes.util import find_library

SQLITE_OK = 0
SQLITE_ERROR = 1
SQLITE_BUSY = 5
SQLITE_LOCKED = 6

SQLITE_OPEN_READONLY = 1
SQLITE_OPEN_READWRITE = 2
SQLITE_OPEN_CREATE = 4

# sqlite = ctypes.CDLL(find_library('sqlite3'))
sqlite = ctypes.CDLL(r'c:\Users\edlip\Documents\code\python\SQLite3\sqlite3.dll')
sqlite.sqlite3_backup_init.restype = ctypes.c_void_p
The code dies in the CDDL call.

Traceback (most recent call last):
File "PCT_DB_backup_sample.py", line 18, in <module>
sqlite = ctypes.CDLL(r'c:\Users\edlip\Documents\code\python\SQLite3\sqlite3.dll')
File "c:\Users\edlip\AppData\Local\Programs\Python\Python36\Lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

I was doing some other Python stuff, hit a SQLite3 can't load error for something which should work (BUKU). I reverted the DLL from a backup and I'm past the error. There must be some issue with the DLL. I'll stay at an older, not bleeding edge, version of SQLite3.
Reply
#2
(Jan-23-2018, 10:16 PM)edlipson Wrote: OSError: [WinError 193] %1 is not a valid Win32 application
Means always that there are a mix up 32-bit/64-bit,
so in your case i guess DLL is 32-bit and you use 64-bit Python.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Script getting reindexing only valid error cubangt 1 921 Dec-07-2023, 04:06 PM
Last Post: cubangt
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 1,574 Jul-31-2023, 11:42 AM
Last Post: deanhystad
Question Use function, retry until valid Ashcora 8 1,468 Jan-06-2023, 10:14 AM
Last Post: Ashcora
  WinError 2, since fresh new Windows 10 install alok 1 1,650 Jan-06-2022, 11:20 PM
Last Post: lucasbazan
  checking for valid hexadecimal digits Skaperen 3 6,394 Sep-02-2021, 07:22 AM
Last Post: buran
  Python library for win32 console commands eldiener 3 3,469 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Win32\ping.exe windows pops up -very annoying... tester_V 9 3,226 Aug-12-2021, 06:54 AM
Last Post: tester_V
  How to send data from a python application to an external application aditya_rajiv 1 2,180 Jul-26-2021, 06:00 AM
Last Post: ndc85430
Exclamation binwalk Win32 compile hackstunt 2 3,812 Feb-24-2021, 05:14 PM
Last Post: nilamo
  pyarrow throws oserror winerror 193 1 is not a valid win32 application aupres 2 3,785 Oct-21-2020, 01:04 AM
Last Post: aupres

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020