Dec-08-2017, 09:39 AM
Pages: 1 2
Dec-08-2017, 09:52 AM
Reducing the imports. If you've big modules, they are also put into the distribution.
Which imports do you have?
Which imports do you have?
Dec-08-2017, 03:06 PM
A normal small script with example using Tkinter.
Pyinstaller make a single .exe around 8-10MB.
As mention bye DeaD_EyE have to look at your import,at whats needed and what can be excluded.
Pyinstaller make a single .exe around 8-10MB.
As mention bye DeaD_EyE have to look at your import,at whats needed and what can be excluded.
Dec-15-2017, 03:47 AM
(Dec-08-2017, 09:52 AM)DeaD_EyE Wrote: [ -> ]Reducing the imports. If you've big modules, they are also put into the distribution.
Which imports do you have?
i would like to import modules below; how I code it for smaller size? i am using pyinstaller.
from tkinter import *
from tkinter import filedialog
import tkinter.ttk as ttk
import os
import pandas as pd
import glob
from pandas import ExcelWriter
from pandas import ExcelFile
import time, sys
Dec-15-2017, 03:52 AM
If your doing pandas under anaconda, try not using anaconda to build the exe.
Dec-15-2017, 04:33 PM
(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 is
23.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 my
work_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:
Error: No module named 'pandas._libs.tslibs.timedeltas'
Open spec(auto generated every time run pyinstaller) file and add:hiddenimports=['pandas._libs.tslibs.timedeltas'],Now run spec file:
(build_env) E:\1py_div\build_env λ pyinstaller --clean work_data.specFinish i have one
work_data.exe
that run pandas and size is 23.4MB
.Dec-18-2017, 10:17 AM
(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?
Dec-18-2017, 04:27 PM
(Dec-18-2017, 10:17 AM)issac_n Wrote: [ -> ]I follow all instructions and manage to generate exe without Error and it is 200MB.You most have,what the size of you
Confused did I miss out something?
build_env
folder?Mine are 174MB this is with all libraries and the build
work_data.exe
23.4MB.All should be run from that folder,you can check
site-packages
folder,and see that pandas ans numpy has normal size pandas(43mb), numpy(27MB).
When virtual environment is activate all should be used from that folder.
I use cmder who has
which
command.# Activate you must see (build_env) λ E:\1py_div\build_env\Scripts\Activate # See that only this folder is used (build_env) E:\1py_div\build_env λ pip -V pip 9.0.1 from e:\1py_div\build_env\lib\site-packages (python 3.6) (build_env) E:\1py_div\build_env λ which python /e/1py_div/build_env/Scripts/python (build_env) E:\1py_div\build_env λ which pyinstaller /e/1py_div/build_env/Scripts/pyinstallerCan you post your whole scripts not just the imports?
Dec-19-2017, 03:41 AM
(Dec-18-2017, 04:27 PM)snippsat Wrote: [ -> ](Dec-18-2017, 10:17 AM)issac_n Wrote: [ -> ]I follow all instructions and manage to generate exe without Error and it is 200MB.You most have,what the size of you
Confused did I miss out something?build_env
folder?
Mine are 174MB this is with all libraries and the buildwork_data.exe
23.4MB.
All should be run from that folder,you can checksite-packages
folder,
and see that pandas ans numpy has normal size pandas(43mb), numpy(27MB).
When virtual environment is activate all should be used from that folder.
I use cmder who haswhich
command.
# Activate you must see (build_env) λ E:\1py_div\build_env\Scripts\Activate # See that only this folder is used (build_env) E:\1py_div\build_env λ pip -V pip 9.0.1 from e:\1py_div\build_env\lib\site-packages (python 3.6) (build_env) E:\1py_div\build_env λ which python /e/1py_div/build_env/Scripts/python (build_env) E:\1py_div\build_env λ which pyinstaller /e/1py_div/build_env/Scripts/pyinstallerCan you post your whole scripts not just the imports?
I notice my site-packages folder is empty and the exe file is in dist folder;
and is return <root> instead of " <build_env>" after activate it; .
u can click the image link for full image. will pm the full script to u.
Dec-19-2017, 05:02 PM
I have tested with code you send me,and i make a working .exe of that code with size of
The problem is that you are doing something wrong when making the environment.
Here is all step taken from
Python version used is 3.6 as shown in tutorial here and part-2 has info about virtual environment.
Start
23.4MB
.The problem is that you are doing something wrong when making the environment.
Here is all step taken from
cmd
,run cmd as administrator.Python version used is 3.6 as shown in tutorial here and part-2 has info about virtual environment.
Start
cmd
Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. Med enerett. C:\WINDOWS\system32>cd\ C:\>e: # Make folder Test3 E:\>mkdir Test3 # cd into folder E:\>cd Test3 # Make virtual environment E:\Test3>python -m venv build_env # cd into build folder E:\Test3>cd build_env # Activate environment E:\Test3\build_env>E:\Test3\build_env\Scripts\activate.bat # See (build_env) and test that pip use this folder (build_env) E:\Test3\build_env>pip -V pip 9.0.1 from e:\test3\build_env\lib\site-packages (python 3.6) # Install Pyinstaller (build_env) E:\Test3\build_env>pip install pyinstaller Collecting pyinstaller Downloading PyInstaller-3.3.1.tar.gz (3.5MB) 100% |████████████████████████████████| 3.5MB 333kB/s Requirement already satisfied: setuptools in e:\test3\build_env\lib\site-packages (from pyinstaller) Collecting pefile>=2017.8.1 (from pyinstaller) Collecting macholib>=1.8 (from pyinstaller) Using cached macholib-1.9-py2.py3-none-any.whl Collecting future (from pyinstaller) Collecting pypiwin32 (from pyinstaller) Using cached pypiwin32-220-cp36-none-win32.whl Collecting altgraph>=0.15 (from macholib>=1.8->pyinstaller) Using cached altgraph-0.15-py2.py3-none-any.whl Installing collected packages: future, pefile, altgraph, macholib, pypiwin32, pyinstaller Running setup.py install for pyinstaller ... done Successfully installed altgraph-0.15 future-0.16.0 macholib-1.9 pefile-2017.11.5 pyinstaller-3.3.1 pypiwin32-220 (build_env) E:\Test3\build_env>Now it work continue first with Pandas dependencies as shown before in post.
Pages: 1 2