Pyinstaller in virtual environment still yields very large EXE file
I have a Python code of 78 lines using the following packages:
import pandas as pd
import base64
from bs4 import BeautifulSoup
import os
import win32com.client as win32
import pathlib
I ran the following commands:
venv\Scripts\activate
python -m pip install pandas
python -m pip install pybase64
python -m pip install bs4
python -m pip install pywin32
python -m pip install pyinstaller
pyinstaller --onefile to_HTML.py
I have created a virtual environment in which I installed only the above packages.
Yet the EXE file created is 740Mb!!
What am I doing wrong? How can I reduce it?
Answer
It doesn't look like you've installed pyinstaller within your virtual environment. I suspect it's attempting to use your global pyinstaller, which may be attempting to wrap any other packages you've installed globally.
Try this:
venv\Scripts\activate
python -m pip install pyinstaller
# install other dependencies as needed
venv\Scripts\pyinstaller.exe --onefile to_HTML.py
Based on my quick test case, I get a very different file size when running with the virtual environment pyinstaller vs. the global one.