Re: [Win11 PyInstall ctypes dll] OSError: exception: access violation reading 0x0000000000000000

40 views
Skip to first unread message
Message has been deleted

Elliot Garbus

unread,
Aug 8, 2024, 9:47:56 AM8/8/24
to PyInstaller
I'm not familiar with visPy.  My assumption is that there is a dependency for VisPy that Pyinstaller can not detect.  
Is there a dependency of VisPy or a selectable "backend" for VisPy?

If so look at importing the these dependencies into your main.py so pyinstaller can see them, or add to the hidden-imports list in pyinstaller.

On Thursday, August 8, 2024 at 2:45:12 AM UTC-7 Yang Chen wrote:
My Python script works just fine, but something wrong with the exe generated by PyInstaller.

Error message:
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    print(XReal.get_arr())
  File "XReal.py", line 9, in get_arr
    ptr = self.dll.GetEuler()
OSError: exception: access violation reading 0x0000000000000000


Source code:
XReal.py:

import ctypes
class xreal:
    def __init__(self):
        self.dll = ctypes.CDLL('AirAPI_Windows.dll')
        self.dll.StartConnection()
        self.dll.GetEuler.restype = ctypes.POINTER(ctypes.c_float)
        self.arr = (ctypes.c_float * 3)()
    def get_arr(self):
        ptr = self.dll.GetEuler()
        ctypes.memmove(self.arr, ptr, ctypes.sizeof(self.arr))
        return list(self.arr)
XReal = xreal()

main.py:
from XReal import XReal
while True:
    print(XReal.get_arr())
import vispy # If this line is commented out, the exe generated works as expected.

The PyInstaller command:
pyinstaller main.py

Environment information:
OS: Win11
Python: 3.7.5
PyInstaller: 5.13.2
VisPy: 0.6.4
AirAPI_Windows.dll: https://github.com/MSmithDev/AirAPI_Windows/tree/master

Any suggestions?

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages