Used pyinstaller

sudo pyinstaller -D -f -n main -c "name_of_file.py"

This will create a dist folder which will contain the executable for linux.
Must have pyinstaller installed
sudo pip3 install pyinstaller
