If anyone has experience with pyinstaller and accessible_output2, I am trying to package a program that uses it. The program works great uncompiled, but once made into a .exe, it complains about not finding nvdaControllerClient.dll. I have tried everything I and LLMs can think of and nothing seems to fix it. Any pointers would be much appreciated.
The program in question is a launcher for the Toby Doom project that will replace all the existing .bat files and offer much better customization for game play. I could just ship it as a .py, but that would mean asking Windows users to install python and pip install dependencies. This is why I want to make the .exe.
@storm Do you instruct pyinstaller to copy the stuff included in accessible_output2 to the folder of the exe? https://pyinstaller.org/en/stable/usage.html
@sukiletxe thanks for the hint. I think I am closer now. The error has changed, it's complaining about not being able to find speechd which is not imported in Windows. I added exclude module speechd and it still happens. Also, it checks for a socket file on Linux systems and windows is complaining about not being able to find that. The command I used to generate the spec file is:
pyinstaller --exclude-module speechd "Toby Doom Launcher.py"
It generates the dist folder with a Toby doom Launcher folder inside it. In that folder are Toby Doom Launcher.exe and _internal/ which contains all the stuff it needs. I think if I can get it to stop trying to import the linux stuff, it should work now, this is much different than what it had before that was failing to import nvdaControllerClient.dll. This is how I have my imports set up. I'm not really sure it's 100% correct, I don't do much development for Windows:
# Initialize speech provider based on platform
if platform.system() == "Windows":
# Set up DLL paths for Windows
if getattr(sys, 'frozen', False):
# If running as compiled executable
dll_path = os.path.join(sys._MEIPASS, 'lib')
if os.path.exists(dll_path):
os.add_dll_directory(dll_path)
# Also add the executable's directory
os.add_dll_directory(os.path.dirname(sys.executable))
# Initialize Windows speech provider
try:
import accessible_output2.outputs.auto
s = accessible_output2.outputs.auto.Auto()
speechProvider = "accessible_output2"
except ImportError as e:
print(f"Failed to initialize accessible_output2: {e}")
sys.exit()
else:
# Linux/Mac path
try:
output = subprocess.check_output(["pgrep", "cthulhu"])
speechProvider = "cthulhu"
except (subprocess.CalledProcessError, FileNotFoundError):
try:
import accessible_output2.outputs.auto
s = accessible_output2.outputs.auto.Auto()
speechProvider = "accessible_output2"
except ImportError as e:
try:
import speechd
spd = speechd.Client()
speechProvider = "speechd"
except ImportError:
print("No speech providers found.")
sys.exit()
I know there are Mac references in the comments, and I do plan on getting there eventually, but I have this problem to fix vfirst. ☺️
@sukiletxe it's working now. Thanks for the pointer, it was what ultimately lead to the solution.
- replies
- 0
- announces
- 0
- likes
- 0