24

I installed Anaconda 3 2.3.0 on Windows xp. It is supposed to be the last version of anaconda to support windows xp as it contains python 3.4.3, and python 3.4.x is the last version of python to support windows xp.

When installing a package with

conda install

,one of its dependencies was updating conda to conda 4.x. conda 4.x crashed in the commandline when running conda install . This made anaconda unusable that i uninstalled anaconda.

My question, is it possible to lock versions of packages ? For the two use cases:

  • lock and forget : for packages I never want them to update, i need to run a command to lock them once so they will never update as a depency
  • ignore updating : install a package while ignoring to update certain package passed by name in this update.

If only one of the 2 use cases is possible or is known or is easier, please write it as answer.

darthbith
  • 18,484
  • 9
  • 60
  • 76
Mohamed El-Nakeep
  • 6,580
  • 4
  • 35
  • 39

3 Answers3

37

There are two bits to this. First, you can prevent conda from auto-updating by changing the configuration option auto_update_conda to False:

conda config --set auto_update_conda False

The other bit is to pin packages to certain versions. For those packages you don't want to update, you can pin the version by adding a line to a file called pinned (you might need to create it) in the environment's conda-meta directory. The syntax is

[The code] below [placed in conda-meta/pinned] forces NumPy to stay on the 1.7 series, which is any version that starts with 1.7, and forces SciPy to stay at exactly version 0.14.2:

numpy 1.7.*
scipy ==0.14.2

See the documentation for more information.

Community
  • 1
  • 1
darthbith
  • 18,484
  • 9
  • 60
  • 76
  • The first command that disables auto update of conda works on conda 5.0.1 but not on conda 2.3.0 – Mohamed El-Nakeep Feb 11 '18 at 23:20
  • however the second trick - the one with pinned file- works. I put conda in pinned file to disable its updates and it works! It now generates 'Error: Unsatisfiable package specifications.' when installation requires updating conda. – Mohamed El-Nakeep Feb 11 '18 at 23:35
  • 1
    I couldn't pin the python binary that I built myself even with your solutions. For example, even when I do this `conda install numpy ... python=3.6.3-0`, my conda tries `python: 3.6.3-0 ...torch_fork/conda-bld --> 3.6.3-h6c0c0dc_5` –  Jan 06 '19 at 15:36
  • You can pin the channel of a package, but I'm not sure how to do that. Please ask a new question and include your complete input and output – darthbith Jan 06 '19 at 17:27
  • I pinned two packages to pip builds because conda builds [were failing](https://stackoverflow.com/a/54628478/974555), with `llvmlite==0.27.0-pypi` and `numba==0.42.0-pypi`. – gerrit Feb 11 '19 at 16:30
  • echo $CONDA_PREFIX can be used to lookup your env where you can add to `conda-meta/pinned` – random-forest-cat Dec 19 '20 at 23:03
1

Pin for conda install (=): package=1.0

vs.

Pin for pip install (==): package==1.0

mirekphd
  • 4,799
  • 3
  • 38
  • 59
-2

Try

pip install <package name==version no*>

for instance

pip install musdb==0.2.*

That would pin your package

Joaquim
  • 380
  • 4
  • 10
  • Please see the official documentation https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#:~:text=Pinning%20a%20package%20specification%20in,you%20do%20not%20want%20updated. – Joaquim Jun 20 '20 at 15:48
  • It's related to conda pm not pip. – Coddy Dec 10 '20 at 17:04