Python Forum
Shrink Python installation? Extract site-packages from .zip only on demand?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shrink Python installation? Extract site-packages from .zip only on demand?
#1
I installed recently to full Python on my Windows 10 system.

As I noticed this installation requires huge 4,85 GB (!) disk space.
Ok, I still have 90 GB free on my 1 TB SSD. But I would feel better if it would be smaller.
Python is by far my biggest space consuming software on my disk/SSD.
I am thinking about how users can reduce disk space for Python.

Since I am not a heavy Python user but uses it only occasionally and only some packages I can think of the following mechanism:

All "site-packages" remain zipped until there are really imported in a Python script.
Only if a Python script runs which executes an import this (and only this !) package is extracted from *.zip archive.

Is this somehow possible?
Reply
#2
I don't know what you have installed, but 4.85 Gb doesn't look normal to me
Gribouillis likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I agree with buran. First scan the site-packages directory with a program such as filelight or windirstat to see how the space is filled.
« We can solve any problem by introducing an extra level of indirection »
Reply
#4
The Python-Installation is small. Packages like Qt, Tensorflow or other AI-Toolkits are very big. I guess you've installed packages via PIP.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#5
Original installation from python.org 3.13 Windows installer (64-bit) is packed 26.9 MB and unpacked on disk 160 MB(so far away from 4,85 GB )
So if have install a lot stuff via pip the size can be bigger.
As mention if install eg Tensorflow or other AI-Toolkits are very big,here is recommend to use virtual environment.
Then have all in one folder and have full control of size and can just delete that folder.
venv is build into Python and easy to use.
# Make 
G:\div_code
λ python -m venv panda_env

# cd in
G:\div_code
λ cd panda_env\

# Activate
G:\div_code\panda_env
λ G:\div_code\panda_env\Scripts\activate.bat

# Install
G:\div_code\panda_env
(panda_env) λ pip install pandas
Collecting pandas
  Downloading pandas-2.2.3-cp312-cp312-win_amd64.whl.metadata (19 kB)
Collecting numpy>=1.26.0 (from pandas)
  Downloading numpy-2.1.2-cp312-cp312-win_amd64.whl.metadata (59 kB)
     ---------------------------------------- 59.7/59.7 kB 634.7 kB/s eta 0:00:00
Collecting python-dateutil>=2.8.2 (from pandas)
  Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz>=2020.1 (from pandas)
  Downloading pytz-2024.2-py2.py3-none-any.whl.metadata (22 kB)
Collecting tzdata>=2022.7 (from pandas)
  Downloading tzdata-2024.2-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.2->pandas)
  Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Downloading pandas-2.2.3-cp312-cp312-win_amd64.whl (11.5 MB)
   ---------------------------------------- 11.5/11.5 MB 1.9 MB/s eta 0:00:00
Downloading numpy-2.1.2-cp312-cp312-win_amd64.whl (12.6 MB)
   ---------------------------------------- 12.6/12.6 MB 1.8 MB/s eta 0:00:00
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Downloading pytz-2024.2-py2.py3-none-any.whl (508 kB)
   ---------------------------------------- 508.0/508.0 kB 2.0 MB/s eta 0:00:00
Downloading tzdata-2024.2-py2.py3-none-any.whl (346 kB)
   ---------------------------------------- 346.6/346.6 kB 2.0 MB/s eta 0:00:00
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: pytz, tzdata, six, numpy, python-dateutil, pandas
Successfully installed numpy-2.1.2 pandas-2.2.3 python-dateutil-2.9.0.post0 pytz-2024.2 six-1.16.0 tzdata-2024.2

[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip

G:\div_code\panda_env
(panda_env) λ
So the folder is now 130 mb with Python and Pandas,and now i can just delete panda_env folder and place is free again.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  White Screen Issue with Toolbar After Python Installation evelynfreya 2 1,055 Nov-25-2024, 06:26 PM
Last Post: deanhystad
  Install a module to a specific to Python Installation (one of many)) tester_V 2 2,073 Oct-29-2024, 03:25 PM
Last Post: snippsat
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 3 8,278 Oct-01-2024, 03:32 PM
Last Post: Alex_Kirpichny
  Troubleshooting Jupyter Notebook installation with Python using pip and a venv Drone4four 1 2,247 Jun-04-2024, 10:55 PM
Last Post: Drone4four
  Python installation for old MacOS Yonix 1 1,085 Sep-21-2023, 03:32 PM
Last Post: menator01
  Installing python packages in a virtual environment Led_Zeppelin 1 1,628 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Installation of packages to newest Python version from previous one Andrzej_Andrzej 3 4,569 Jul-15-2023, 11:32 AM
Last Post: snippsat
  How to see the date of installation of python modules. newbieAuggie2019 4 4,573 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Getting "SSL client not supported by this Python installation" error prabirsarkar 0 1,631 Mar-13-2023, 05:01 PM
Last Post: prabirsarkar
  python installation/running inside singularity container erdemath 2 3,192 Sep-21-2022, 08:13 AM
Last Post: erdemath

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020