Issue after creating .exe while using wexpect within the script

280 views
Skip to first unread message

Blake D.

unread,
Jan 7, 2022, 4:06:35 AM1/7/22
to PyInstaller

Capture.PNG
This is the error message I keep receiving. I've tried to do what ' https://github.com/raczben/wexpect/wiki/Wexpect-with-pyinstaller ' says and I followed it exactly but I still receive the exact same error as seen above. I also tried importing the missing module as a hidden import (--hidden-import=...) but that did not work either. I am also very new to python so that doesn't help me very much in troubleshooting. Any guidance will be greatly appreciated!

bwoodsend

unread,
Jan 10, 2022, 4:07:29 AM1/10/22
to PyInstaller

That’s a bug in wexpect. See here where they’re misusing the __init__.py as a regular module. It should be just from . import spawn. Try changing that line in your copy and if it works, I'll ask the wexpect devs to change it permanently.

Blake D.

unread,
Jan 18, 2022, 3:01:21 AM1/18/22
to PyInstaller
Please ignore the last message as I did not understand what was recommended until just now. So i went to the host.py file and made the update to line 103 to "from . import spawn" and I am now receiving this error message after using pyinstaller and creating the script into one file.
new error.PNG

Blake D.

unread,
Jan 18, 2022, 3:01:27 AM1/18/22
to PyInstaller
original.png

^^^This is part of my original code and I do not have the same " from .__init__ import spawn" as per the example sent, but I still tried to add "from . import spawn" as recommended and I got this error.

Capture1.PNG
Capture4.PNG

I also tried compiling the code below with swapping the "." for "wexpect" and got the same error from the original code.
Capture2.png
Capture.PNG
On Monday, January 10, 2022 at 3:07:29 AM UTC-6 bwoodsend wrote:

bwoodsend

unread,
Jan 18, 2022, 6:29:38 PM1/18/22
to PyInstaller

That’s this line telling you that the ./wexpect/wexpect.exe it was hoping to find isn’t there. This will be where those rather odd instructions from that wiki page you shared come in. You’ll need to build wexpect.exe and place it inside your application.

Blake D.

unread,
Jan 19, 2022, 1:09:51 PM1/19/22
to PyInstaller
Thank you, It works perfectly now after fixing the bug on line 103 of host.py for wexpect and by using the instructions listed here, https://github.com/raczben/wexpect/wiki/Wexpect-with-pyinstaller

I now have another question. The compiled folders of my script + wexpect are full of many different files and I am curious of how I may be able to compress all this down to a single .exe file or to a few of them? Since I can't use the "onefile" feature of pyinstaller due to wexpect, I am now looking for an alternative way to have the minimal amount of required files in order to properly run my script on a new windows environment that doesn't have python.

Eric Fahlgren

unread,
Jan 20, 2022, 4:26:12 AM1/20/22
to pyins...@googlegroups.com
Once you've got a pile of files that need to be moved to other machine en masse, you're out of PyInstaller's domain.  You need to look at NSIS or MSI or Inno Setup or one of the other packages that put all those files into an installer that can then be shipped to end users.  I've used all three of those mentioned, and I'd say Inno Setup is the easiest to get started with.

Of course, you could always "go cheap" and just put everything into a .zip and tell your users, "unzip this somewhere, then click on the .exe..."  Above mentioned installers basically do exactly this, plus give you a good mechanism to create shortcuts with icons, set registry entries and all that fancy stuff.

Blake D.

unread,
Feb 1, 2022, 5:15:20 AM2/1/22
to PyInstaller
Thank you for the suggestions but after using them to package my script, my script would no long function properly after being unpackaged. But I am actually looking for a way to condense my script, which utilizes wexpect, to a single .exe file. Like as if you were to use pyinstaller --onefile myscript.py. However, wexpect does not work with --onefile so I'm looking for some workaround or another way to create a single .exe file of my script. Currently my script runs properly using the method found here, https://github.com/raczben/wexpect/wiki/Wexpect-with-pyinstaller. This method leaves me with 3,000+ files within a folder, which is not desirable. 
Reply all
Reply to author
Forward
0 new messages