如何卸载除pip之外的系统Python包(为了最佳实践)

时间:2018-05-07 16:38:20

标签: python pip pycharm

我正在尝试遵循Python的环境设置最佳实践,如下所述。 https://averlytics.com/2017/08/06/virtual-environment-a-python-best-practice/

本文的重点是仅在虚拟环境中安装软件包,并避免在系统上安装任何其他东西。我试图通过完全删除Pycharm,Anaconda,Python并从头开始重新安装来遵循这种做法。

之后,我一直试图在Pycharm(venv)上设置虚拟环境来完成我的工作。

但是,我认为我在默认终端上pip install ...犯了一两个错误,导致系统再次安装了系统。

我真的想回到最佳实践安装的轨道,但不想完成整个卸载和重新安装过程。

我在我的PowerShell上检查了pip list但是我不知道应该留下哪一个以及我应该卸载哪一个,因为可能有一些软件包可以保留我的Anaconda和Pycharm以及整个工作。我不想从这个问题中提出另一个问题。

我该怎么办?离开它们是否为时已晚? “保持最小的系统安装并在虚拟环境中完成所有安装”的事情到目前为止仍然有效吗?

我希望有人教过我比安装Python并首先使用IDLE更好的方法。

以下是已安装软件包的列表。

PS C:\WINDOWS\system32> pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
absl-py (0.2.0)
alabaster (0.7.10)
anaconda-client (1.6.9)
anaconda-navigator (1.8.4)
anaconda-project (0.8.2)
asn1crypto (0.24.0)
astor (0.6.2)
astroid (1.6.1)
astropy (2.0.3)
attrs (17.4.0)
Babel (2.5.3)
backports.shutil-get-terminal-size (1.0.0)
beautifulsoup4 (4.6.0)
bitarray (0.8.1)
bkcharts (0.2)
blaze (0.11.3)
bleach (1.5.0)
bokeh (0.12.13)
boto (2.48.0)
Bottleneck (1.2.1)
certifi (2018.1.18)
cffi (1.11.4)
chardet (3.0.4)
click (6.7)
cloudpickle (0.5.2)
clyent (1.2.2)
colorama (0.3.9)
comtypes (1.1.4)
conda (4.4.10)
conda-build (3.4.1)
conda-verify (2.0.0)
contextlib2 (0.5.5)
cryptography (2.1.4)
cycler (0.10.0)
Cython (0.27.3)
cytoolz (0.9.0)
dask (0.16.1)
datashape (0.5.4)
decorator (4.2.1)
distributed (1.20.2)
docutils (0.14)
entrypoints (0.2.3)
et-xmlfile (1.0.1)
fastcache (1.0.2)
filelock (2.0.13)
Flask (0.12.2)
Flask-Cors (3.0.3)
gast (0.2.0)
gevent (1.2.2)
glob2 (0.6)
greenlet (0.4.12)
grpcio (1.11.0)
h5py (2.7.1)
heapdict (1.0.0)
html5lib (0.9999999)
idna (2.6)
imageio (2.2.0)
imagesize (0.7.1)
ipykernel (4.8.2)
ipython (6.2.1)
ipython-genutils (0.2.0)
ipywidgets (7.1.1)
isort (4.2.15)
itsdangerous (0.24)
jdcal (1.3)
jedi (0.11.1)
Jinja2 (2.10)
jsonschema (2.6.0)
jupyter (1.0.0)
jupyter-client (5.2.2)
jupyter-console (5.2.0)
jupyter-core (4.4.0)
jupyterlab (0.31.4)
jupyterlab-launcher (0.10.2)
lazy-object-proxy (1.3.1)
llvmlite (0.21.0)
locket (0.2.0)
lxml (4.1.1)
Markdown (2.6.11)
MarkupSafe (1.0)
matplotlib (2.1.2)
mccabe (0.6.1)
menuinst (1.4.11)
mistune (0.8.3)
mpmath (1.0.0)
msgpack-python (0.5.1)
multipledispatch (0.4.9)
navigator-updater (0.1.0)
nbconvert (5.3.1)
nbformat (4.4.0)
networkx (2.1)
nltk (3.2.5)
nose (1.3.7)
notebook (5.4.0)
numba (0.36.2)
numexpr (2.6.4)
numpy (1.14.0)
numpydoc (0.7.0)
odo (0.5.1)
olefile (0.45.1)
openpyxl (2.4.10)
packaging (16.8)
pandas (0.22.0)
pandocfilters (1.4.2)
parso (0.1.1)
partd (0.3.8)
path.py (10.5)
pathlib2 (2.3.0)
patsy (0.5.0)
pep8 (1.7.1)
pickleshare (0.7.4)
Pillow (5.0.0)
pip (9.0.1)
pkginfo (1.4.1)
pluggy (0.6.0)
ply (3.10)
prompt-toolkit (1.0.15)
protobuf (3.5.2.post1)
psutil (5.4.3)
py (1.5.2)
pycodestyle (2.3.1)
pycosat (0.6.3)
pycparser (2.18)
pycrypto (2.6.1)
pycurl (7.43.0.1)
pyflakes (1.6.0)
Pygments (2.2.0)
pylint (1.8.2)
pyodbc (4.0.22)
pyOpenSSL (17.5.0)
pyparsing (2.2.0)
PySocks (1.6.7)
pytest (3.3.2)
python-dateutil (2.6.1)
pytz (2017.3)
PyWavelets (0.5.2)
pywin32 (222)
pywinpty (0.5)
PyYAML (3.12)
pyzmq (16.0.3)
QtAwesome (0.4.4)
qtconsole (4.3.1)
QtPy (1.3.1)
requests (2.18.4)
rope (0.10.7)
ruamel-yaml (0.15.35)
scikit-image (0.13.1)
scikit-learn (0.19.1)
scipy (1.0.0)
seaborn (0.8.1)
Send2Trash (1.4.2)
setuptools (38.4.0)
simplegeneric (0.8.1)
singledispatch (3.4.0.3)
six (1.11.0)
snowballstemmer (1.2.1)
sortedcollections (0.5.3)
sortedcontainers (1.5.9)
Sphinx (1.6.6)
sphinxcontrib-websupport (1.0.1)
spyder (3.2.6)
SQLAlchemy (1.2.1)
statsmodels (0.8.0)
sympy (1.1.1)
tables (3.4.2)
tblib (1.3.2)
tensorboard (1.8.0)
tensorflow (1.8.0)
termcolor (1.1.0)
terminado (0.8.1)
testpath (0.3.1)
toolz (0.9.0)
tornado (4.5.3)
traitlets (4.3.2)
typing (3.6.2)
unicodecsv (0.14.1)
urllib3 (1.22)
wcwidth (0.1.7)
webencodings (0.5.1)
Werkzeug (0.14.1)
wheel (0.30.0)
widgetsnbextension (3.1.0)
win-inet-pton (1.0.1)
win-unicode-console (0.5)
wincertstore (0.2)
wrapt (1.10.11)
xlrd (1.1.0)
XlsxWriter (1.0.2)
xlwings (0.11.5)
xlwt (1.3.0)
zict (0.1.3)

1 个答案:

答案 0 :(得分:1)

将已安装的软件包列表创建为文件:

pip freeze > requirements.txt

编辑txt文件以排除您要保留的所有包。从你的列表中,我认为python附带的唯一软件包是pip和setuptools。通常virtualenv也有,但我没有在你的名单上看到它。 您可以删除除这些之外的所有内容,然后运行

pip uninstall -r requirements.txt

或者一次性删除所有内容:

pip uninstall -r requirements.txt -y

资料来源: What is the easiest way to remove all packages installed by pip?

或者,您始终可以删除安装并重新安装。

看起来你有点乱,所以这可能就是我要做的。

如果你有很多virtualenvs,你可能需要在python重新安装后重新创建它们,所以请确保你的每个virtualenv项目中的requirements.txt文件中都有你的依赖项

相关问题