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?
Asked
Active
Viewed 4,019 times
3 Answers
10
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

Siu Ching Pong -Asuka Kenji-
- 7,943
- 8
- 53
- 74
-
2Got to learn some cool terminal tricks. – sgalpha01 Nov 07 '21 at 13:16
5
Another simple method: conda update --all python=3.5.2
Replace the python version with your currently installed version. This will update all packages, and since the target version for python
is already installed, it will not be updated. This also works with multiple packages: conda update all python=3.5.2 spyder=3.3.6
.

klwire
- 123
- 1
- 9
3
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
.

LexMulier
- 273
- 3
- 13