简体   繁体   中英

Python Selenium GUI to an executable

I have never made an executable application before but from what I have read its pretty easy, using py2exe to generate the exe. But I have a GUI that uses Selenium to scrape data from a backend (No I can not use API calls). How do I add chromedriver to the executable? Also, would all the imports go along when using a compiler?

When you compile a .py file into an .exe (from my personal experience) all of the imports are included.

I would personally suggest using pyinstaller. I had quite a few problems using py2exe and as a beginner I found pyinstaller much more user-friendly and easier to troubleshoot.

As compiling a file does not alter the .py file, I would suggest getting it to a fully working state and trying it. If it doesn't appear to work or if some of the imports are lost, we can troubleshoot with the error code.

You can also use cx_Freeze to create an executable from your python script.

You can install cx_Freeze by issuing the command

python -m pip install cx_Freeze --upgrade

in a cmd prompt / terminal.

As far as tkinter is concerned, you'll find a working example of how to freeze a tkinter -based application with the current version of cx_Freeze in this answer . In the setup.py script you find there, you need to replace the name of the Executable by the name of your main script. Place this setup.py in the same directory than your main script and run

python setup.py build

from a cmd prompt / terminal.

As far as chromedriver is concerned, I've no experience, if you choose this approach and still have problems, please add the exact error message and a Minimal, Complete, and Verifiable example to your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM