What I am trying to do is create a batch file to create a virtual environment, install requirements, and then use pyinstaller to convert the python file to an executable.
I have a folder (.venv) with the following folders/files:
In the parent folder there is:
The Code:
copy fileName.py .venv
copy icon.ico .venv
cd .venv
@echo off
Set "out=."
(
Echo;pytube==15.0.0
Echo;moviepy==1.0.3
Echo;keyboard==0.13.5
) > "%out%\requirements.txt"
echo;requirements.txt created
@echo on
python -m venv fileName
cmd /k "pip install -r requirements.txt"
fileName\Scripts\activate.bat
pyinstaller fileName.py -F --icon=icon.ico --upx-dir upx
start /b "" "python.exe" "pyinstaller fileName.py -F --icon=icon.ico --upx-dir upx
cmd /k "pyinstaller fileName.py -F --icon=icon.ico --upx-dir upx
Thank You Alexander and Mofi for the help.
Including pyinstaller in the requirements.txt file reduced the file size by 50% and the call function worked perfectly. This is my final code:
copy fileName.py .venv
copy icon.ico .venv
cd .venv
@echo off
Set out="."
(
Echo;pytube==15.0.0
Echo;moviepy==1.0.3
Echo;keyboard==0.13.5
Echo;pyinstaller==5.10.1
) > "%out%\requirements.txt"
echo;requirements.txt created
@echo on
python -m venv fileName
pip install -r requirements.txt
call fileName\Scripts\activate.bat
pyinstaller fileName.py -F --icon=icon.ico --upx-dir upx