1

I just used pip to install Silx in an existing Anaconda environment (called gssw). Pip then started to install Numpy (one of the dependencies of Silx) even though my environment already contained an older version of Numpy that was installed as a regular conda package. To my understanding this should not happen!

I now have two numpy packages in my enviromnent.

(gssw) C:\>conda list numpy
# packages in environment at C:\Anaconda\envs\gssw:
#
numpy                     1.11.2                   py35_0
numpy                     1.15.0                    <pip>

When start Python it seems to use the latter.

(gssw) C:\>python -c "import numpy; print(numpy.__version__)"
1.15.0

Here is my conda info

(gssw) C:\>conda info
Current conda install:

               platform : win-64
          conda version : 4.3.30
       conda is private : False
      conda-env version : 4.3.30
    conda-build version : 1.11.0
         python version : 2.7.9.final.0
       requests version : 2.12.4
       root environment : C:\Anaconda  (writable)
    default environment : C:\Anaconda\envs\gssw
       envs directories : C:\Anaconda\envs
                          C:\Users\kenter\AppData\Local\conda\conda\envs
                          C:\Users\kenter\.conda\envs
          package cache : C:\Anaconda\pkgs
                          C:\Users\kenter\AppData\Local\conda\conda\pkgs
           channel URLs : https://repo.continuum.io/pkgs/main/win-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
            config file : None
             netrc file : None
           offline mode : False
             user-agent : conda/4.3.30 requests/2.12.4 CPython/2.7.9 Windows/7 Windows/6.1.7601
          administrator : False

So my questions are...

  1. I assumed that it is impossible to have two packages with the same name in one enviroment. Is that correct or do I misunderstand how Anaconda works?

  2. What went wrong here?

  3. How to fix it?

Please let me know if you need anymore info.

titusjan
  • 5,376
  • 2
  • 24
  • 43
  • The short answer is, don't use pip to install packages into conda environments, or at least, don't mix pip and conda to install packages. I'm not sure of the specific reason (in the code for conda and pip) why this occurs, but you can also reproduce it going the other way: https://stackoverflow.com/a/45919845/2449192 To fix it, `pip uninstall` all the packages and `conda install` them (or vice versa) – darthbith Jul 25 '18 at 13:49
  • Thanks for the link @darthbith. I have had this problem before with PyQt but I thought that was a special case because there the packages names were different with pip and anaconda. But this means that it is worse than I thought, apparently you cannot mix packages that have any dependencies at all. (Unless you use `pip --no-deps`, but then how do you use this in a conda environment file?). Luckily in this case I've found there are Silx packages on conda-forge. – titusjan Jul 26 '18 at 08:19
  • I've only noticed this happening for packages with C-libraries, although I wouldn't swear that's the reason. For instance, you can do `conda install sphinx` and `pip install sphinxcontrib-doxylink` and the second command will pick up the Sphinx that's already been installed. – darthbith Jul 26 '18 at 11:02
  • @darthbith what?? It is very clear that conda is intended to support pip. you can do conda install pip, and then install packages using pip. "Avoiding it" shouldn't be a solution. – Gulzar Dec 22 '18 at 12:32
  • @Gulzar Why? This is explicitly recommended by Anaconda themselves! From a recent [blog post](https://www.anaconda.com/blog/developer-blog/using-pip-in-a-conda-environment/): "There are a few steps which can be used to avoid broken environments when using conda and pip together. One surefire method is to only use conda packages." – darthbith Dec 22 '18 at 14:55
  • I think that there are a handful of packages that don't play nicely if you use pip, but in general conda doesn't have all packages, so sometimes you need pip. Particularly with numpy, conda requires you to not use pip to install it ([ref](https://github.com/conda-forge/numpy-feedstock/issues/84#issuecomment-385218166)) – davzaman May 09 '19 at 19:45

0 Answers0