(Dec-15-2017, 04:33 PM)snippsat Wrote:(Dec-15-2017, 03:47 AM)issac_n Wrote: how I code it for smaller size? i am using pyinstaller.You using pandas that can have a lot of dependencies.
Like is using Numpy+MKL(it can use 200mb) more that may not be need.
So just install numpy alone.
To have control over dependencies must use virtual environment.
I have tested with all your import and my file size with all for one .exe file is23.4MB
.
Here is the whole setup,i use virtual environment that's build into 3.6.
There are basic dependencies that pandas need.
Dependencies:
- setuptools
- NumPy: 1.9.0 or higher
- python-dateutil: 1.5 or higher
- pytz: Needed for time zone support
Setup virtual environment,i use cmder but is just the same commands in cmd:
# Make E:\1py_div λ python -m venv build_env # cd in E:\1py_div λ cd build_env # Activate E:\1py_div\build_env λ E:\1py_div\build_env\Scripts\Activate (build_env) E:\1py_div\build_env # Install pyinstaller λ pip install pyinstaller Collecting pyinstaller Requirement already satisfied: setuptools in e:\1py_div\build_env\lib\site-packages (from pyinstaller) Collecting future (from pyinstaller) Collecting macholib>=1.8 (from pyinstaller) Downloading macholib-1.9-py2.py3-none-any.whl (40kB) 100% |████████████████████████████████| 40kB 998kB/s Collecting pefile>=2017.8.1 (from pyinstaller) Collecting altgraph>=0.15 (from macholib>=1.8->pyinstaller) Downloading altgraph-0.15-py2.py3-none-any.whl Installing collected packages: future, altgraph, macholib, pefile, pyinstaller Successfully installed altgraph-0.15 future-0.16.0 macholib-1.9 pefile-2017.11.5 pyinstaller-3.3So now have environment with pyinstaller.
Installing dependencies:
(build_env) E:\1py_div\build_env λ pip install numpy Collecting numpy Using cached numpy-1.13.3-2-cp36-none-win32.whl Installing collected packages: numpy Successfully installed numpy-1.13.3 (build_env) E:\1py_div\build_env λ pip install python-dateutil pytz setuptools Collecting python-dateutil Using cached python_dateutil-2.6.1-py2.py3-none-any.whl Collecting pytz Using cached pytz-2017.3-py2.py3-none-any.whl Requirement already satisfied: setuptools in e:\1py_div\build_env\lib\site-packages Collecting six>=1.5 (from python-dateutil) Using cached six-1.11.0-py2.py3-none-any.whl Installing collected packages: six, python-dateutil, pytz Successfully installed python-dateutil-2.6.1 pytz-2017.3 six-1.11.0 (build_env) E:\1py_div\build_env λ pip install pandas Collecting pandas Downloading pandas-0.21.1-cp36-cp36m-win32.whl (8.2MB) 100% |████████████████████████████████| 8.2MB 158kB/s Requirement already satisfied: numpy>=1.9.0 in e:\1py_div\build_env\lib\site-packages (from pandas) Requirement already satisfied: pytz>=2011k in e:\1py_div\build_env\lib\site-packages (from pandas) Requirement already satisfied: python-dateutil>=2 in e:\1py_div\build_env\lib\site-packages (from pandas) Requirement already satisfied: six>=1.5 in e:\1py_div\build_env\lib\site-packages (from python-dateutil>=2->pandas) Installing collected packages: pandas Successfully installed pandas-0.21.1 (build_env) E:\1py_div\build_env λ pip install pypiwin32 Collecting pypiwin32 Using cached pypiwin32-220-cp36-none-win32.whl Installing collected packages: pypiwin32 Successfully installed pypiwin32-220I place mywork_data.py
(that use pandas) in environment to make sure that all import work.
I build with:
(build_env) E:\1py_div\build_env λ pyinstaller -F work_data.pyThere is a problem:
Open spec(auto generated every time run pyinstaller) file and add:
Error:No module named 'pandas._libs.tslibs.timedeltas'
hiddenimports=['pandas._libs.tslibs.timedeltas'],Now run spec file:
(build_env) E:\1py_div\build_env λ pyinstaller --clean work_data.specFinish i have onework_data.exe
that run pandas and size is23.4MB
.
I follow all instructions and manage to generate exe without Error and it is 200MB.
did I miss out something?
possible to further minimize the size?