我通过pew使用virtualenv(我认为这是一个很棒的工具),但我发现了一些奇怪的东西。
我安装了scipy系统端:
7,7 MiB [##########] /sparse
5,1 MiB [###### ] /special
5,1 MiB [###### ] /stats
5,0 MiB [###### ] /linalg
3,5 MiB [#### ] /spatial
3,0 MiB [### ] /optimize
2,5 MiB [### ] /signal
2,3 MiB [### ] /interpolate
2,3 MiB [## ] /misc
2,2 MiB [## ] /io
1,5 MiB [## ] /integrate
1,3 MiB [# ] /ndimage
1,0 MiB [# ] /fftpack
744,0 KiB [ ] /cluster
512,0 KiB [ ] /odr
464,0 KiB [ ] /constants
252,0 KiB [ ] /_lib
44,0 KiB [ ] /_build_utils
36,0 KiB [ ] /__pycache__
24,0 KiB [ ] HACKING.rst.txt
12,0 KiB [ ] THANKS.txt
8,0 KiB [ ] INSTALL.rst.txt
4,0 KiB [ ] __init__.py
4,0 KiB [ ] __config__.py
4,0 KiB [ ] LICENSE.txt
4,0 KiB [ ] setup.py
4,0 KiB [ ] BENTO_BUILD.txt
4,0 KiB [ ] version.py
4,0 KiB [ ] linalg.pxd
这是scipy virtualenv-side安装(相同的scipy版本):
51,0 MiB [##########] /sparse
37,6 MiB [####### ] /.libs
12,9 MiB [## ] /linalg
10,6 MiB [## ] /spatial
9,7 MiB [# ] /special
6,0 MiB [# ] /interpolate
5,9 MiB [# ] /stats
5,1 MiB [# ] /optimize
4,2 MiB [ ] /signal
3,2 MiB [ ] /io
3,0 MiB [ ] /integrate
3,0 MiB [ ] /ndimage
2,3 MiB [ ] /misc
2,1 MiB [ ] /cluster
1,7 MiB [ ] /fftpack
884,0 KiB [ ] /odr
328,0 KiB [ ] /constants
204,0 KiB [ ] /_lib
32,0 KiB [ ] /_build_utils
24,0 KiB [ ] HACKING.rst.txt
20,0 KiB [ ] /__pycache__
12,0 KiB [ ] THANKS.txt
8,0 KiB [ ] INSTALL.rst.txt
4,0 KiB [ ] __init__.py
4,0 KiB [ ] LICENSE.txt
4,0 KiB [ ] setup.py
4,0 KiB [ ] __config__.py
4,0 KiB [ ] BENTO_BUILD.txt
4,0 KiB [ ] version.py
4,0 KiB [ ] pip-delete-this-directory.txt
4,0 KiB [ ] linalg.pxd
毋庸置疑,存在巨大的差异。它通常不会打扰我,但我正在尝试使用pyinstaller捆绑可执行文件,并且生成的可执行文件实际上太大了。
有人可以解释这样的差异吗?它不是特定的scipy,我也看到它为numpy,也许对其他库。
编辑:
目录中的文件具有不同的大小:
系统范围:
3,1 MiB [##########] _sparsetools.cpython-35m-x86_64-linux-gnu.so
VIRTUALENV范围:
38,5 MiB [##########] _sparsetools.cpython-35m-x86_64-linux-gnu.so
答案 0 :(得分:5)
为Scipy分发的Python轮中的共享库文件不会被剥离,因此它们比包管理器安装的大:
merge
如果您strip it,文件大小会缩小:
$ file _sparsetools.cpython-35m-x86_64-linux-gnu.so
_sparsetools.cpython-35m-x86_64-linux-gnu.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ed7b8e00c558f234620423315fa9b53274393e72, not stripped
$ du -h _sparsetools.cpython-35m-x86_64-linux-gnu.so
39M _sparsetools.cpython-35m-x86_64-linux-gnu.so
PyInstaller可以使用--strip
flag为您执行此操作。