Hide the console in Python Selenium
Running Python Selenium causes the ChromeDriver console …
Published:
PyInstaller makes it easy to create an exe, but I didn’t know how to create multiple exe’s in one folder, so I looked into it.
Prepare python sample files as appropriate.
In this case, we will use the following hello1.py and hello2.py.
# hello1.py
#
print('hello 1')
# hello2.py
#
print('hello 2')
Create spec files for both hello1.py and hello2.py.
Running the following will create the files hello1.spec and hello2.spec.
pyi-makespec hello1.py
pyi-makespec hello2.py
The pyi-makespec
is included with the PyInstaller installation.
If you open the spec file, you will see the following (some parts are omitted because it is long).
What’s inside is actually python code.
# hello1.spec
...
a = Analysis(['hello1.py'], ...)
pyz = PYZ(a.pure, a.zipped_data, ...)
exe = EXE(pyz,
a.scripts,
... )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
...)
PyInstaller builds the app based on the contents of the spec file.
By modifying this spec file in a good way, you can “create multiple exe’s in one folder”.
Create a single spec file by merging the contents of hello1.spec and hello2.spec.
Create a file named hello.spec and write the following while using the two spec files as a basis.
# hello.spec
...
hello1_a = Analysis(['hello1.py'], ...)
hello1_pyz = PYZ(hello1_a.pure, hello1_a.zipped_data, ...)
hello1_exe = EXE(hello1_pyz,
hello1_a.scripts,
...)
hello2_a = Analysis(['hello2.py'], ...)
hello2_pyz = PYZ(hello2_a.pure, hello2_a.zipped_data, ...)
hello2_exe = EXE(hello2_pyz,
hello2_a.scripts,
...)
coll = COLLECT(hello1_exe,
hello1_a.binaries,
hello1_a.zipfiles,
hello1_a.datas,
hello2_exe,
hello2_a.binaries,
hello2_a.zipfiles,
hello2_a.datas,
...
name='hello')
Copy and paste the Analysis
, PYZ
, and EXE
parts, and modify the variable names so that they are not duplicated.
Copy and paste the COLLECT
part as well, but only one, and change the argument.
pyinstaller hello.spec
When execution is complete, a folder named hello will be created under the dist folder, and hello1.exe and hello2.exe will be created in it.
Running Python Selenium causes the ChromeDriver console …
This is a method of compressing a folder into a ZIP file …
Replace strings in Excel cells with Python. It can be used …
Make a program created with Python & Selenium into an …
PyInstaller can be used to convert a program created with …
Describes how to convert an Excel sheet to PDF using Python. …