Issue
I have developed a python application that records the users' actions on the web using the following packages
python==3.7.9
selenium==4.0.0
seleniumbase==2.1.9
Tinkerer==1.7.2
tqdm==4.62.3
validators==0.18.2
I have tried to use a lot of different approaches to convert into an exe file that will require nothing to be installed on the client's side I have tried using the following
pyvan
and it did not work and I opened an issue to the pkg's authorpyinstaller
and when I run my code, it always tells me that the librarySeleniumBase
is unknown and the solution is to install it on the customer side WHICH IS NOT AN OPTIONpipenv
and did not work as wellPyOxidizer
&py2exe
did not work with me as well
I would like to convert that python application into an
exe
(I don't care if it is a single file or folder) as long as it requires no installation on the user's side
Repo Structure
├── requirements.txt
├── main.py
├── logo.ico
├── web_actions_recorder
| ├── main.py
| ├── __init__.py
└── README.md
Solution
I have found a solution/workaround
My application has this line where I am trying to invoke SeleniumBase on the customer side by the following python snippet import os; os.system("sbase mkrec recording.py")
which is not possible as the customer does not have seleniumbase
on his/her PC
The solution is as follows:
Copy from your env Python Folder
C:\Users\<USER_NAME>\AppData\Local\Programs\Python\Python38
and paste it inside your project files.- The folder is called Python38 as I am working with multiple python versions on my PC, this one is named Python38 as it is python version 3.8.10
Edit the code to be as following
import os
# the script was in a folder so I had to do `os.path.dirname(".") first
python_dir_path = os.path.join(os.path.dirname("."), "Python38", "python.exe")
# in that way we will use the python folder with everything installed in
# to help us run the `sbase` command without having to install
# anything on the user's side
os.system(f"{python_path} -m sbase mkrec recording.py")
- Finally use
PyInstaller v4.7
to package the application, in my casepyinstaller --clean --onedir --name <your_app_name> --windowed --hidden-import seleniumbase --icon <path_to_icon> main.py
Answered By - ElSheikh Answer Checked By - Mary Flores (WPSolving Volunteer)