Skip to content

Multiple Python versions are installed in the same image #253

Closed

Description

@vdboor

In the Docker images, multiple Python versions can be found. For example:

Python 2.7, 3.5 and 3.6 in the python:3.6.4-stretch image:

$ docker run python:3.6.4-stretch  bash -c 'ls -d /usr/bin/python?.? /usr/local/bin/python?.? /usr/local/lib/python?.?'
/usr/bin/python2.7
/usr/bin/python3.5
/usr/local/bin/python3.6
/usr/local/lib/python2.7
/usr/local/lib/python3.5
/usr/local/lib/python3.6

Python 2.7 and 3.6 in the python:3.6.3 image:

$ docker run python:3.6.4  bash -c 'ls -d /usr/bin/python?.? /usr/local/bin/python?.? /usr/local/lib/python*'
/usr/bin/python2.7
/usr/local/bin/python3.6
/usr/local/lib/python2.7
/usr/local/lib/python3.6

Can this be fixed somehow?

Fortunately, the -slim packages seem to have one proper Python version installed.

Activity

  1. tianon commented on Jan 2, 2018

    @tianon
    Member

    This is kind of an unfortunate side-effect of our use of buildpack-deps in the non-slim variants -- some of the packages that it includes require Python, and there's not a lot we can do to fix that (it's the nature of including the whole kitchen sink).

    We have made sure that PATH is set appropriately such that the Python installed by this image is preferred.

    $ docker pull python:3
    3: Pulling from library/python
    f49cf87b52c1: Already exists 
    7b491c575b06: Already exists 
    b313b08bab3b: Already exists 
    51d6678c3f0e: Already exists 
    09f35bd58db2: Already exists 
    0f9de702e222: Pull complete 
    73911d37fcde: Pull complete 
    99a87e214c92: Pull complete 
    Digest: sha256:b7411c363d4206930dd47a9bf668157bd99ba4ea3e5174ec4c25776c5b1abe9a
    Status: Downloaded newer image for python:3
    
    $ docker run -it --rm python:3 bash
    root@86816c8e6aa6:/# apt purge python.*
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Note, selecting 'python-minimal:any' for regex 'python.*'
    Note, selecting 'python-support' for regex 'python.*'
    Note, selecting 'python-all-dbg' for regex 'python.*'
    Note, selecting 'libpython2.7-stdlib' for regex 'python.*'
    Note, selecting 'python2.7-elementtree' for regex 'python.*'
    Note, selecting 'python-argparse' for regex 'python.*'
    Note, selecting 'python-minimal' for regex 'python.*'
    Note, selecting 'python-ctypes' for regex 'python.*'
    Note, selecting 'python-central' for regex 'python.*'
    Note, selecting 'python-all-dev' for regex 'python.*'
    Note, selecting 'python-wsgiref' for regex 'python.*'
    Note, selecting 'python2.7-celementtree' for regex 'python.*'
    Note, selecting 'python-bzrlib-dbg' for regex 'python.*'
    Note, selecting 'python-urllib3' for regex 'python.*'
    Note, selecting 'python-all' for regex 'python.*'
    Note, selecting 'python-apt' for regex 'python.*'
    Note, selecting 'python2.6-minimal' for regex 'python.*'
    Note, selecting 'python2.7-minimal:any' for regex 'python.*'
    Note, selecting 'python2.7-cjkcodecs' for regex 'python.*'
    Note, selecting 'python-gobject' for regex 'python.*'
    Note, selecting 'python2.7' for regex 'python.*'
    Note, selecting 'python-virtualenv' for regex 'python.*'
    Note, selecting 'python-dbg' for regex 'python.*'
    Note, selecting 'python2.7-profiler' for regex 'python.*'
    Note, selecting 'python-gi' for regex 'python.*'
    Note, selecting 'python-dev' for regex 'python.*'
    Note, selecting 'python-4suite' for regex 'python.*'
    Note, selecting 'python-examples' for regex 'python.*'
    Note, selecting 'python-pycurl' for regex 'python.*'
    Note, selecting 'python-configobj-doc' for regex 'python.*'
    Note, selecting 'python2.7-bzrlib' for regex 'python.*'
    Note, selecting 'python-six' for regex 'python.*'
    Note, selecting 'python-profiler' for regex 'python.*'
    Note, selecting 'python' for regex 'python.*'
    Note, selecting 'python-doc' for regex 'python.*'
    Note, selecting 'python-openssl' for regex 'python.*'
    Note, selecting 'python-pygments' for regex 'python.*'
    Note, selecting 'python-gpgme' for regex 'python.*'
    Note, selecting 'python-mysqldb' for regex 'python.*'
    Note, selecting 'libpython-stdlib' for regex 'python.*'
    Note, selecting 'python:any' for regex 'python.*'
    Note, selecting 'python-tk' for regex 'python.*'
    Note, selecting 'python-kerberos' for regex 'python.*'
    Note, selecting 'python2.7-minimal' for regex 'python.*'
    Note, selecting 'python2.7-ctypes' for regex 'python.*'
    Note, selecting 'python-importlib' for regex 'python.*'
    Note, selecting 'python2.7-wsgiref' for regex 'python.*'
    Note, selecting 'python-configobj' for regex 'python.*'
    Note, selecting 'python-bzrlib.tests' for regex 'python.*'
    Note, selecting 'python-email' for regex 'python.*'
    Note, selecting 'python2.5-minimal' for regex 'python.*'
    Note, selecting 'python-bzrlib' for regex 'python.*'
    Note, selecting 'python2.7-doc' for regex 'python.*'
    Note, selecting 'python-paramiko' for regex 'python.*'
    Note, selecting 'python2.7-argparse' for regex 'python.*'
    Note, selecting 'python-launchpadlib' for regex 'python.*'
    Note, selecting 'libpython2.7-minimal' for regex 'python.*'
    Note, selecting 'python3.1-minimal' for regex 'python.*'
    Note, selecting 'python2.7:any' for regex 'python.*'
    Package 'python-configobj-doc' is not installed, so not removed
    Package 'python-bzrlib-dbg' is not installed, so not removed
    Package 'python-bzrlib.tests' is not installed, so not removed
    Package 'python-gpgme' is not installed, so not removed
    Package 'python-kerberos' is not installed, so not removed
    Package 'python-paramiko' is not installed, so not removed
    Package 'python-pycurl' is not installed, so not removed
    Package 'python-launchpadlib' is not installed, so not removed
    Note, selecting 'python-bzrlib' instead of 'python2.7-bzrlib'
    Package 'python-gi' is not installed, so not removed
    Package 'python2.7-doc' is not installed, so not removed
    Note, selecting 'python' instead of 'python-profiler'
    Package 'python-virtualenv' is not installed, so not removed
    Note, selecting 'python2.7' instead of 'python2.7:any'
    Note, selecting 'python' instead of 'python:any'
    Package 'python-central' is not installed, so not removed
    Package 'python-all' is not installed, so not removed
    Package 'python-all-dbg' is not installed, so not removed
    Package 'python-all-dev' is not installed, so not removed
    Package 'python-dbg' is not installed, so not removed
    Package 'python-dev' is not installed, so not removed
    Package 'python-examples' is not installed, so not removed
    Package 'python-support' is not installed, so not removed
    Package 'python2.5-minimal' is not installed, so not removed
    Package 'python2.6-minimal' is not installed, so not removed
    Package 'python3.1-minimal' is not installed, so not removed
    Note, selecting 'python-minimal' instead of 'python-minimal:any'
    Package 'python-mysqldb' is not installed, so not removed
    Package 'python-pygments' is not installed, so not removed
    Package 'python-openssl' is not installed, so not removed
    Package 'python-gobject' is not installed, so not removed
    Package 'python-apt' is not installed, so not removed
    Package 'python-4suite' is not installed, so not removed
    Package 'python-urllib3' is not installed, so not removed
    Note, selecting 'libpython2.7-stdlib' instead of 'python-argparse'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-argparse'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-celementtree'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-cjkcodecs'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-ctypes'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-elementtree'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-profiler'
    Note, selecting 'libpython2.7-stdlib' instead of 'python2.7-wsgiref'
    Package 'python-doc' is not installed, so not removed
    Package 'python-tk' is not installed, so not removed
    Note, selecting 'python' instead of 'python-ctypes'
    Note, selecting 'python' instead of 'python-email'
    Note, selecting 'python' instead of 'python-importlib'
    Note, selecting 'python' instead of 'python-wsgiref'
    Note, selecting 'python2.7-minimal' instead of 'python2.7-minimal:any'
    The following packages were automatically installed and are no longer required:
      gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-rsvg-2.0 libcairo-gobject2 libcairo-script-interpreter2 libcdt5 libcgraph6
      libdjvulibre-dev libelfg0 libexif-dev libexif12 libexpat1-dev libfontconfig1-dev libfreetype6-dev libgd3 libgirepository-1.0-1 libglib2.0-bin
      libgraphviz-dev libgvc6 libgvpr2 libice-dev libice6 libilmbase-dev libjasper-dev libjbig-dev libjs-excanvas libjs-jquery liblcms2-dev
      liblqr-1-0-dev liblzo2-2 libmagickcore-6-arch-config libmagickcore-6-headers libmagickwand-6-headers libopenexr-dev libpathplan4 libpcre3-dev
      libpcrecpp0 libpixman-1-dev libpthread-stubs0-dev libsm-dev libsm6 libtiff5-dev libtiffxx5 libvpx1 libwmf-dev libx11-dev libxau-dev
      libxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxdmcp-dev libxdot4 libxext-dev libxpm4 libxrender-dev libxt-dev libxt6 mime-support pkg-config
      x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-render-dev x11proto-xext-dev xorg-sgml-doctools xtrans-dev
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
      bzr* libcairo2-dev* libgdk-pixbuf2.0-dev* libglib2.0-dev* libmagickcore-6.q16-dev* libmagickcore-dev* libmagickwand-6.q16-dev*
      libmagickwand-dev* libpython-stdlib* libpython2.7-minimal* libpython2.7-stdlib* librsvg2-dev* mercurial* mercurial-common* python*
      python-bzrlib* python-configobj* python-minimal* python-six* python2.7* python2.7-minimal*
    0 upgraded, 0 newly installed, 21 to remove and 0 not upgraded.
    After this operation, 56.8 MB disk space will be freed.
    Do you want to continue? [Y/n] 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions