Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
580 views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)?

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...