Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does sys.path have "c:\\windows\\system\python34.zip"?

When I imported sys,

>>> import sys
>>> sys.path
['', 'C:\\Program Files\\Python 3.5\\lib\\site-packages\\pyinstaller-3.0-py3.5.egg', **'C:\\Program Files\\Python 3.5\\python35.zip'**, 'C:\\Program Files\\Python 3.5\\DLLs', 'C:\\Program Files\\Python 3.5\\lib', 'C:\\Program Files\\Python 3.5', 'C:\\Program Files\\Python 3.5\\lib\\site-packages', 'C:\\Program Files\\Python 3.5\\lib\\site-packages\\win32', 'C:\\Program Files\\Python 3.5\\lib\\site-packages\\win32\\lib', 'C:\\Program Files\\Python 3.5\\lib\\site-packages\\Pythonwin']`

I checked whether there is a file like python34.zip in the directory, but the answer is no. Why is it showing?

like image 580
shiva prasanth Avatar asked Sep 05 '26 22:09

shiva prasanth


1 Answers

The whole lib folder included in a Python installation can be zipped in an archive, named python3x.dll, with x depending on your Python release.

This is useful if you need to work whith a minimal, standalone, dedicated version of Python for some project, and helps if you intend to redistribute Python with your application, so users don't need to install Python to run it.

starting from Python 3.5, you can download an official embeddable version for windows, with a zipped python35.zip included - and no lib folder obviously.

Actually, I didn't test to zip a 3.4 release or below, yet, but I will soon. directions should be : compile every py to pyc or pyo, remove pycache folders, remove any libraries you don't need(*), check stackoverflow and python doc.

(*) you can use apps like Process Monitor, it will tell you which file are used by python during your app runtime.

like image 59
jerome Avatar answered Sep 07 '26 12:09

jerome



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!