python - 从 Linux 系统中删除所有非必要的 Python 包

标签 python linux

在我开始使用之前 Anaconda为了管理我的项目的虚拟环境,我安装了所有 Python 包:

pip install <package>

或最差

sudo pip install <package>

既然我已经习惯了使用虚拟环境,我想删除我在我的 Linux 系统(基本操作系统,基于 Ubuntu 16.04 64 位)中安装的所有非必要软件包 A pip freeze返回:

$ pip freeze
alabaster==0.7.9
anaconda-clean==1.0
anaconda-client==1.6.0
anaconda-navigator==1.4.3
argcomplete==1.0.0
astroid==1.4.7
astropy==1.2.1
Babel==2.3.4
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.5.1
bitarray==0.8.1
blaze==0.10.1
bokeh==0.12.3
boto==2.43.0
bottle==0.12.10
Bottleneck==1.1.0
cffi==1.8.3
chest==0.2.3
click==6.6
cloudpickle==0.2.1
clyent==1.2.2
colorama==0.3.7
conda==4.3.16
conda-build==2.0.8
configobj==5.0.6
contextlib2==0.5.3
cryptography==1.5.2
cssselect==1.0.0
cycler==0.10.0
Cython==0.25.1
cytoolz==0.8.0
d2to1==0.2.12.post1
dask==0.11.1
datashape==0.5.2
decorator==4.0.10
dill==0.2.5
docutils==0.12
dynd==0.7.3.dev1
et-xmlfile==1.0.1
fastcache==1.0.2
feedfinder2==0.0.4
feedparser==5.2.1
filelock==2.0.6
Flask==0.11.1
Flask-Cors==2.1.2
gevent==1.1.2
glueviz==0.9.1
greenlet==0.4.10
h5py==2.6.0
HeapDict==1.0.0
idna==2.1
imagesize==0.7.1
ipykernel==4.5.0
ipython==5.1.0
ipython-genutils==0.1.0
ipywidgets==5.2.2
itsdangerous==0.24
jdcal==1.3
jedi==0.9.0
jieba3k==0.35.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.4.0
jupyter-console==5.0.0
jupyter-core==4.2.0
lazy-object-proxy==1.2.1
llvmlite==0.14.0
locket==0.2.0
lxml==3.6.4
Markdown==2.6.7
Markdown-Editor==1.0.1
MarkupSafe==0.23
matplotlib==1.5.3
mistune==0.7.3
mpmath==0.19
multipledispatch==0.4.9
nb-anacondacloud==1.2.0
nb-conda==2.0.0
nb-conda-kernels==2.0.0
nbconvert==4.2.0
nbformat==4.1.0
nbpresent==3.0.2
networkx==1.11
newspaper3k==0.1.7
nltk==3.2.1
nose==1.3.7
notebook==4.2.3
numba==0.29.0
numexpr==2.6.1
numpy==1.11.2
odo==0.5.0
openpyxl==2.4.0
pandas==0.19.1
partd==0.3.6
path.py==0.0.0
pathlib2==2.1.0
patsy==0.4.1
pep8==1.7.0
pexpect==4.0.1
pickleshare==0.7.4
Pillow==3.4.2
pkginfo==1.3.2
ply==3.9
prompt-toolkit==1.0.8
psutil==5.0.0
ptyprocess==0.5.1
py==1.4.31
pyasn1==0.1.9
pycosat==0.6.1
pycparser==2.16
pycrypto==2.6.1
pycurl==7.43.0
pyflakes==1.3.0
Pygments==2.1.3
pylint==1.5.4
pyOpenSSL==16.2.0
pyparsing==2.1.4
pytest==3.0.3
python-dateutil==2.5.3
pytz==2016.7
PyYAML==3.12
pyzmq==16.0.0
QtAwesome==0.3.3
qtconsole==4.2.1
QtPy==1.2.1
redis==2.10.5
requests==2.12.4
requests-file==1.4.1
rope-py3k==0.9.4.post1
ruamel-yaml===-VERSION
scikit-image==0.12.3
scikit-learn==0.18
scipy==0.18.1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
snowballstemmer==1.2.1
sockjs-tornado==1.0.3
Sphinx==1.4.8
spyder==3.0.1
SQLAlchemy==1.1.3
statsmodels==0.6.1
stsci.distutils==0.3.7
stsci.tools==3.4
sympy==1.0
tables==3.3.0
terminado==0.6
tldextract==2.0.2
toolz==0.8.0
tornado==4.4.2
traitlets==4.3.1
unicodecsv==0.14.1
wcwidth==0.1.7
Werkzeug==0.11.11
widgetsnbextension==1.2.6
wrapt==1.10.8
xlrd==1.0.0
XlsxWriter==0.9.3
xlwt==1.1.2

我知道其中一些我可以使用 pip uninstall <package> 轻松删除,但我想知道是否有更简单的方法将其重置为仅系统必需的包(而不会有破坏我的系统的风险)。

最佳答案

我认为如果通过 Apt 或类似工具安装 .deb 包完全没有问题,因为它们会拉取自己的依赖项。

如果你做了一些时髦的事情,那么:

对于 dpkg -l 中列出的每个包,我将运行 apt-cache show $package 和 grep “Depends:”、“Recommends:”,也许还有“Suggests” :",并隔离那些 python-* 和 python3-* 包的名称。

关于python - 从 Linux 系统中删除所有非必要的 Python 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43954471/

相关文章:

Python SSL 导入错误

linux - 大查询 : Does bq load command support loading from named pipe as a source?

c++ - 是否可以在没有任何外部库的情况下在 c++/linux 的窗口中显示 bmp 图像?

linux - 在 Eclipse CDT 中的 Linux 机器上交叉调试 Windows 应用程序

linux - 自动添加带空格的 SVN 命令行

python - 使用 pyplot 中的箭袋函数绘制箭头的对数长度

python - 在我自己的应用程序中使用 Django 管理外观

java - 为什么Tomcat不保留最小堆空间

python - geopandas 可以获取 geopackage(或其他矢量文件)的所有图层吗?

python - 如何检索所有图像、js、css url