For this you need to create a separate environment, because currently you are reading all the modules you have installed on your computer. To create environment run commands
1 - if you don't have one, create a requirements.txt
file that holds all packages that you are using, you could create one with:
pip freeze > requirements.txt
2 - create env folder:
python -m venv projectName
3 - activate the environment:
source projectName/bin/activate
4 - install them:
pip install -r requirements.txt
alternatively if you know you are using only wxpython you could just pip install wxpython
5 - then finally you can run pyinstaller
on your main script with the --path
arg as explained in this answer:
pyinstaller --paths projectName/lib/python3.7/site-packages script.py