Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda update packages except python

I am a beginner in python and I am using an older version of anaconda which has the 3.5.2 version of python, because I would like to use tensorflow with it. I have some outdated packages that I would like to update with "conda update all". Is there a way to do this without updating python from 3.5 to 3.6, which is incompatible with tensorflow?

like image 753
idrispendisbey Avatar asked Feb 05 '23 12:02

idrispendisbey


2 Answers

Short Answer

conda update --all --dry-run 2>/dev/null |
    grep -Fe '-->' |
    cut -d' ' -f3 |
    grep -ve 'python' |
    xargs conda update

Long Answer

Step 1: Dry run to check packages to be updated

Command

conda update --all --dry-run

Result

Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: //anaconda3/envs/general


The following packages will be UPDATED:

  astroid                                      2.3.1-py37_0 --> 2.3.2-py37_0
  ca-certificates                               2019.8.28-0 --> 2019.10.16-0
  openssl                                 1.0.2t-h1de35cc_1 --> 1.1.1d-h1de35cc_3
  pip                                         19.2.3-py37_0 --> 19.3.1-py37_0
  pylint                                       2.4.2-py37_0 --> 2.4.3-py37_0
  python                                   3.7.0-hc167b69_0 --> 3.7.4-h359304d_1
  sqlite                                  3.30.0-ha441bb4_0 --> 3.30.1-ha441bb4_0



DryRunExit: Dry run. Exiting.

Step 2: Get rid of messages from stderr (optional, but clearer)

Command

conda update --all --dry-run 2>/dev/null

Result

Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: //anaconda3/envs/general


The following packages will be UPDATED:

  astroid                                      2.3.1-py37_0 --> 2.3.2-py37_0
  ca-certificates                               2019.8.28-0 --> 2019.10.16-0
  openssl                                 1.0.2t-h1de35cc_1 --> 1.1.1d-h1de35cc_3
  pip                                         19.2.3-py37_0 --> 19.3.1-py37_0
  pylint                                       2.4.2-py37_0 --> 2.4.3-py37_0
  python                                   3.7.0-hc167b69_0 --> 3.7.4-h359304d_1
  sqlite                                  3.30.0-ha441bb4_0 --> 3.30.1-ha441bb4_0

Step 3: Extract the lines with package names

Command

conda update --all --dry-run 2>/dev/null |
    grep -Fe '-->'

Result

  astroid                                      2.3.1-py37_0 --> 2.3.2-py37_0
  ca-certificates                               2019.8.28-0 --> 2019.10.16-0
  openssl                                 1.0.2t-h1de35cc_1 --> 1.1.1d-h1de35cc_3
  pip                                         19.2.3-py37_0 --> 19.3.1-py37_0
  pylint                                       2.4.2-py37_0 --> 2.4.3-py37_0
  python                                   3.7.0-hc167b69_0 --> 3.7.4-h359304d_1
  sqlite                                  3.30.0-ha441bb4_0 --> 3.30.1-ha441bb4_0

Step 4: Produce a list of package names

Command

conda update --all --dry-run 2>/dev/null |
    grep -Fe '-->' |
    cut -d' ' -f3

Note: Since there are 2 spaces in front of each package name, the package name is the 3rd field of the line. This leads to the argument -f3.

Result

astroid
ca-certificates
openssl
pip
pylint
python
sqlite

Step 5: Remove the package(s) not requiring update from the list

Command

conda update --all --dry-run 2>/dev/null |
    grep -Fe '-->' |
    cut -d' ' -f3 |
    grep -ve 'python'

Result

astroid
ca-certificates
openssl
pip
pylint
sqlite

Step 6: Update the packages from the list

Command

conda update --all --dry-run 2>/dev/null |
    grep -Fe '-->' |
    cut -d' ' -f3 |
    grep -ve 'python' |
    xargs conda update
like image 192
Siu Ching Pong -Asuka Kenji- Avatar answered Feb 16 '23 04:02

Siu Ching Pong -Asuka Kenji-


You can either update them all manually conda update yourpackage

...or you could update them all conda update --all, and then downgrade python again with conda install python=3.5.2.

like image 31
LexMulier Avatar answered Feb 16 '23 04:02

LexMulier