Skip to content

Instantly share code, notes, and snippets.

@zthxxx
Created April 17, 2018 12:22
Show Gist options
  • Save zthxxx/e589179f2df8d06774bf654301c27cfc to your computer and use it in GitHub Desktop.
Save zthxxx/e589179f2df8d06774bf654301c27cfc to your computer and use it in GitHub Desktop.
bundle python package to win exe (support pandas)
@echo off
if not exist venv/ call init.bat
call venv\Scripts\activate.bat
pyinstaller -F main.py --hidden-import=pandas._libs.tslibs.timedeltas
call venv\Scripts\deactivate.bat
rd /s/q build
@echo off
set PYTHON_CMD=python
where /q python3
if "%ERRORLEVEL%" == "0" (
set PYTHON_CMD=python3
goto :INITIALIZE
)
where /q python
if "%ERRORLEVEL%" == "1" (
echo Please install python!
goto :EOF
)
:INITIALIZE
%PYTHON_CMD% -c "import venv"
if "%ERRORLEVEL%" == "1" (
%PYTHON_CMD% -m pip install virtualenv
%PYTHON_CMD% -m virtualenv venv
) else (
%PYTHON_CMD% -m venv venv
)
call venv\Scripts\activate.bat
pip install -r requirements.txt
@echo off
if not exist venv/ call init.bat
cmd /k venv\Scripts\activate.bat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment