When redistributing python exe, seleniumwire ca.crt not found in temp folder
See original GitHub issueOn the machine that I coded on, the chrome browser opens by selenium using the chromedriver. When I convert code to .exe it still runs the same as it would in the IDE.
When I use the .exe on another machine which still has python installed but not selenium/wire, then it runs into this problem when trying to open.
[Errno 2] No such file or directory: 'C:\\Users\\Owner\\AppData\\Local\\Temp\\_MEI123722\\seleniumwire\\ca.crt'
After manually putting the certificate (ca.crt) into the folder and run again, I get this problem.
Note that I’m using a tkinter button to start the browser so that’s why the _MEI123722
doesn’t change. If I did reload the program then it changes to something like _MEI123801
[Errno 2] No such file or directory: 'C:\\Users\\Owner\\AppData\\Local\\Temp\\_MEI123722\\seleniumwire\\ca.key'
How can I fix this so I can make my software distributable.
I’m running Windows on both machines, using python 3.9(64).
Issue Analytics
- State:
- Created 2 years ago
- Comments:30 (7 by maintainers)
To resolve this error it’s necessary to tell pyinstaller about the two certificate files using the
--add-data
option when you compile the binary. This allows pyinstaller to handle the calls made by Selenium Wire when Selenium Wire first loads the certificates. (Selenium Wire uses the standard mechanism ofpkgutil.get_data()
to load these files internally.)Steps:
--add-data
when you run pyinstaller - for example:(where
my_prog.py
is the name of your script - change as appropriate.)You can discard the two local certificate files once the binary has been built.
If running on Mac/Linux, use a
:
for the separator, e.g.--add-data 'ca.crt:seleniumwire'
Solved the issue lol. The proper script for windows is pyinstaller --add-data ca.crt;seleniumwire --add-data ca.key;seleniumwire --onefile does not work with the ’ added