Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does conda update packages from pypi installed using pip install?

I use Anaconda (because it is awesome), and the packages available through conda install are quite extensive. However now and then I do need to install a package that isn't available in the conda repositories, and so get it from pypi instead.

My question: when I run the command conda update --all, will conda also update these pypi packages? Or do I have to update them separately? The conda docs don't seem to contain an answer to this. This question and answer seems to indicate that no, conda does not manage pypi packages, but I'm still uncertain.

like image 280
Rick supports Monica Avatar asked May 30 '17 14:05

Rick supports Monica


People also ask

Can conda install from PyPI?

If you want to build conda packages for PyPI packages, the recommended way is to use conda skeleton pypi package and use conda build package on the recipe that it creates. To install the package, use conda install --use-local package (here and elsewhere, package is the name of the PyPI package you wish to install).

What is the difference between using pip install and conda install?

The fundamental difference between pip and Conda packaging is what they put in packages. Pip packages are Python libraries like NumPy or matplotlib . Conda packages include Python libraries (NumPy or matplotlib ), C libraries ( libjpeg ), and executables (like C compilers, and even the Python interpreter itself).

Does pip and conda work together?

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side (by installing pip with conda install pip ) but they do not interoperate either.

Does pip pull from PyPI?

pip is installing the packages from PyPi, yes. On the PyPi website you can find links to github where you can find the full package code, but where pip download is PyPi.


3 Answers

No, conda update and conda install don't update packages installed with pip (or install them using pip).

These conda commands only check your "default" anaconda-channels or the ones specified with -c, they ignore everything else. One exception is conda list which shows also the packages installed with pip, these are marked with <pip> and won't be updated.

One example using pip and six:

$ conda create -n testenv python=3.5
Fetching package metadata .................
Solving package specifications: .

Package plan for installation in environment testenv:

The following NEW packages will be INSTALLED:

    pip:            9.0.1-py35_1
    python:         3.5.3-3
    setuptools:     27.2.0-py35_1
    vs2015_runtime: 14.0.25123-0
    wheel:          0.29.0-py35_0

Proceed ([y]/n)? y

$ activate testenv

Installing six with pip (old version):

(testenv) $ pip install six==1.6
Collecting six==1.6
  Downloading six-1.6.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.6.0

conda update doesn't update it (note that six isn't listed in the "all requested packages" but it's listed in conda list):

(testenv) $ conda update --all
Fetching package metadata .................
Solving package specifications: .

# All requested packages already installed.
# packages in environment at testenv:
#
pip                       9.0.1                    py35_1
python                    3.5.3                         3
setuptools                27.2.0                   py35_1
vs2015_runtime            14.0.25123                    0
wheel                     0.29.0                   py35_0

(testenv) $ conda list
# packages in environment at testenv:
#
pip                       9.0.1                    py35_1
python                    3.5.3                         3
setuptools                27.2.0                   py35_1
six                       1.6.0                     <pip>
vs2015_runtime            14.0.25123                    0
wheel                     0.29.0                   py35_0

But it can be upgraded with pip:

(testenv) $ pip install six --upgrade
Collecting six
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
  Found existing installation: six 1.6.0
    Uninstalling six-1.6.0:
      Successfully uninstalled six-1.6.0
Successfully installed six-1.10.0

Just to show that there is a newer version of six in the anaconda channel (which was ignored when I did conda update):

(testenv) $ conda install six
Fetching package metadata .................
Solving package specifications: .

Package plan for installation in environment testenv:

The following NEW packages will be INSTALLED:

    six: 1.10.0-py35_0

Proceed ([y]/n)?
like image 103
MSeifert Avatar answered Oct 10 '22 06:10

MSeifert


This question is old, but here's a batch script that might help with automating this process on Windows. It involves going through conda list and finding packages marked with the pypi tag, which are then subsequently upgraded with pip --upgrade en masse (assuming they are out-of-date; otherwise the standard Requirement already up-to-date message will be returned).

Place the following in a batch file (e.g., condapip.bat) and try it out:

@echo off

set packages=pip install --upgrade
for /f "tokens=1" %%i in ('conda list ^| findstr /R /C:"pypi"') do (call :join %%i)
@echo on
%packages%
@echo off
goto :eof

:join
set packages=%packages% %1
goto :eof
like image 2
davedgd Avatar answered Oct 10 '22 07:10

davedgd


Conda 4.6 has an experimental feature to enable interoperability with pip-installed packages. Use conda config --set pip_interop_enabled true. Non-conda-installed python packages that can be "managed" by conda (i.e. removed) may be updated/changed to satisfy the current solve. Manageable packages were typically installed from wheels. Sdists installed with newer versions of pip are also typically manageable. However conda won't switch out the non-conda-installed package for a conda package if the versions are equivalent.

Non-conda-installed python packages that can't be managed will anchor the environment in place until they are removed by other means. An example of unmanageable packages are "editable" installs that used pip install -e.

All of this applies to conda update --all.

like image 8
kalefranz Avatar answered Oct 10 '22 07:10

kalefranz