conda install -n base --revision 1 doesn't clean up pypi packages

别来无恙 提交于 2021-02-05 07:16:39

问题


I attempted cleaning up my base (mini)conda environment by installing revision 1 of the base environment.

$ conda install -n base --revision 1

For reference, here is what revision 1 means in my case.

$ conda list -n base --revisions
2019-10-24 14:29:57  (rev 0)
    +asn1crypto-1.2.0
    +ca-certificates-2019.10.16
    +certifi-2019.9.11
    +cffi-1.13.0
    +chardet-3.0.4
    +conda-4.7.12
    +conda-package-handling-1.6.0
    +cryptography-2.8
    +idna-2.8
    +libcxx-4.0.1
    +libcxxabi-4.0.1
    +libedit-3.1.20181209
    +libffi-3.2.1
    +ncurses-6.1
    +openssl-1.1.1d
    +pip-19.3.1
    +pycosat-0.6.3
    +pycparser-2.19
    +pyopenssl-19.0.0
    +pysocks-1.7.1
    +python-3.7.4
    +python.app-2
    +readline-7.0
    +requests-2.22.0
    +ruamel_yaml-0.15.46
    +setuptools-41.4.0
    +six-1.12.0
    +sqlite-3.30.0
    +tk-8.6.8
    +tqdm-4.36.1
    +urllib3-1.24.2
    +wheel-0.33.6
    +xz-5.2.4
    +yaml-0.1.7
    +zlib-1.2.11

2019-11-06 20:50:32  (rev 1)
     cffi  {1.13.0 -> 1.13.1}
     setuptools  {41.4.0 -> 41.6.0}
     sqlite  {3.30.0 -> 3.30.1}

Despite the above conda install command, my base environment is still polluted by various python packages, that were installed after revision 1.

$ conda list -n base
# packages in environment at /opt/miniconda3:
#
# Name                    Version                   Build  Channel
absl-py                   0.8.1                    pypi_0    pypi
alabaster                 0.7.12                   pypi_0    pypi
appnope                   0.1.0                    pypi_0    pypi
asn1crypto                1.2.0                    py37_0  
astor                     0.8.0                    pypi_0    pypi
aws-sam-translator        1.21.0                   pypi_0    pypi
aws-xray-sdk              2.4.3                    pypi_0    pypi
babel                     2.8.0                    pypi_0    pypi
bleach                    3.1.0                    pypi_0    pypi
boto                      2.49.0                   pypi_0    pypi
boto3                     1.12.17                  pypi_0    pypi
botocore                  1.15.17                  pypi_0    pypi
ca-certificates           2019.10.16                    0  
certifi                   2019.9.11                py37_0  
cffi                      1.13.1           py37hb5b8e2f_0  
cfn-lint                  0.28.4                   pypi_0    pypi
chardet                   3.0.4                 py37_1003  
conda                     4.7.12                   py37_0  
conda-package-handling    1.6.0            py37h1de35cc_0  
confluence-py             1.0.1                    pypi_0    pypi
coverage                  5.0.3                    pypi_0    pypi
cryptography              2.8              py37ha12b0ac_0  
defusedxml                0.6.0                    pypi_0    pypi
docker                    4.2.0                    pypi_0    pypi
docutils                  0.16                     pypi_0    pypi
ecdsa                     0.15                     pypi_0    pypi
entrypoints               0.3                      pypi_0    pypi
future                    0.18.2                   pypi_0    pypi
gast                      0.2.2                    pypi_0    pypi
google-pasta              0.1.8                    pypi_0    pypi
grpcio                    1.24.3                   pypi_0    pypi
h5py                      2.8.0                    pypi_0    pypi
idna                      2.8                      py37_0  
imagesize                 1.2.0                    pypi_0    pypi
ipython-genutils          0.2.0                    pypi_0    pypi
jmespath                  0.9.5                    pypi_0    pypi
jsondiff                  1.1.2                    pypi_0    pypi
jsonpatch                 1.25                     pypi_0    pypi
jsonpickle                1.3                      pypi_0    pypi
jsonpointer               2.0                      pypi_0    pypi
jupyterlab                1.2.1                    pypi_0    pypi
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.0                    pypi_0    pypi
libcxx                    4.0.1                hcfea43d_1  
libcxxabi                 4.0.1                hcfea43d_1  
libedit                   3.1.20181209         hb402a30_0  
libffi                    3.2.1                h475c297_4  
markdown                  3.1.1                    pypi_0    pypi
mock                      4.0.1                    pypi_0    pypi
moto                      1.3.14                   pypi_0    pypi
nbsphinx                  0.5.1                    pypi_0    pypi
ncurses                   6.1                  h0a44026_1  
numpy                     1.16.4                   pypi_0    pypi
openssl                   1.1.1d               h1de35cc_3  
opt-einsum                3.1.0                    pypi_0    pypi
packaging                 20.3                     pypi_0    pypi
pickleshare               0.7.5                    pypi_0    pypi
pip                       19.3.1                   py37_0  
pluggy                    0.13.1                   pypi_0    pypi
protobuf                  3.10.0                   pypi_0    pypi
ptyprocess                0.6.0                    pypi_0    pypi
py                        1.8.1                    pypi_0    pypi
pyasn1                    0.4.8                    pypi_0    pypi
pycosat                   0.6.3            py37h1de35cc_0  
pycparser                 2.19                     py37_0  
pyflakes                  2.1.1                    pypi_0    pypi
pyinquirer                1.0.3                    pypi_0    pypi
pyopenssl                 19.0.0                   py37_0  
pyparsing                 2.4.6                    pypi_0    pypi
pyrsistent                0.15.5                   pypi_0    pypi
pysocks                   1.7.1                    py37_0  
pytest                    5.3.5                    pypi_0    pypi
pytest-cov                2.8.1                    pypi_0    pypi
pytest-flakes             4.0.0                    pypi_0    pypi
python                    3.7.4                h359304d_1  
python-jose               3.1.0                    pypi_0    pypi
python.app                2                        py37_9  
pytz                      2019.3                   pypi_0    pypi
pyyaml                    5.3                      pypi_0    pypi
pyzmq                     18.1.0                   pypi_0    pypi
readline                  7.0                  h1de35cc_5  
regex                     2019.11.1                pypi_0    pypi
requests                  2.22.0                   py37_0  
responses                 0.10.12                  pypi_0    pypi
rsa                       4.0                      pypi_0    pypi
ruamel_yaml               0.15.46          py37h1de35cc_0  
s3transfer                0.3.3                    pypi_0    pypi
send2trash                1.5.0                    pypi_0    pypi
setuptools                41.6.0                   py37_0  
six                       1.11.0                   pypi_0    pypi
snowballstemmer           2.0.0                    pypi_0    pypi
sphinx                    2.4.4                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.2                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.2                    pypi_0    pypi
sphinxcontrib-htmlhelp    1.0.3                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1                    pypi_0    pypi
sphinxcontrib-qthelp      1.0.3                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.4                    pypi_0    pypi
sqlite                    3.30.1               ha441bb4_0  
sshpubkeys                3.1.0                    pypi_0    pypi
tensorboard               1.15.0                   pypi_0    pypi
tensorflow                1.15.0                   pypi_0    pypi
tensorflow-estimator      1.15.1                   pypi_0    pypi
tensorflow-hub            0.5.0                    pypi_0    pypi
tensorflowjs              1.3.1.1                  pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
terminado                 0.8.2                    pypi_0    pypi
tk                        8.6.8                ha441bb4_0  
tqdm                      4.36.1                     py_0  
urllib3                   1.24.2                   py37_0  
wcwidth                   0.1.7                    pypi_0    pypi
webencodings              0.5.1                    pypi_0    pypi
websocket-client          0.57.0                   pypi_0    pypi
werkzeug                  0.16.0                   pypi_0    pypi
wheel                     0.33.6                   py37_0  
wrapt                     1.11.2                   pypi_0    pypi
xmltodict                 0.12.0                   pypi_0    pypi
xz                        5.2.4                h1de35cc_4  
yaml                      0.1.7                hc338f04_2  
zlib                      1.2.11               h1de35cc_3  

The environment still contains unwanted packages from the pypi channel. Can I only get rid of them via pip uninstall (which is terribly tedious) or there's a nicer / less manual way, like conda install --revision?


回答1:


There is nothing in the Conda CLI to handle this, but pip uninstall also works with a requirements.txt, which could easily be made with this output. For example,

conda list | awk '$4 ~ /^pypi$/ { print $1 }' > requirements.txt
pip uninstall -r requirements.txt

or if you want a one liner

# make sure you have the right environment activated!
pip uninstall -r <(conda list | awk '$4 ~ /^pypi$/ {print $1}')

There is a -y flag for pip uninstall, but I would review the operation, just to double check it is removing from where you expect.



来源:https://stackoverflow.com/questions/63648608/conda-install-n-base-revision-1-doesnt-clean-up-pypi-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!