Your app won’t have directory red/write access once you deploy it to Streamlit Community Cloud and that’s why you’re getting the permission error.
One solution for you would be to pre-download the weights.pth file and include it in your repository then adjust the pix2tex settings to point to this file instead of trying to download it on the first run.