Git Product home page Git Product logo

python2-and-python3-in-docker's Introduction

Python2-and-Python3-in-Docker

Creates a single Docker container lets you run both Python 2.7.13 and Python 3.7.1

TL;DR:$ docker build -t python-2-and-3 .

Starts withpython:3.7.1-alpineand then installs most ofpython:2.7.13-alpineon top to allow you to choose either Python version at runtime via: python2, python3, pip2, pip3

NOTE: site-packages are separate sopip2 install pkgnamedoes not makepkgnameavailable to Python 3. This means that you would also need topip3 install pkgnameto makepkgnameaccessable from both versions of Python.

$ mkdir python-2-and-3
$ cd python-2-and-3

# <put `Dockerfile` into that directory...>
$ docker build -t python-2-and-3 .
$ docker images  # python-2-and-3 should be at the top of the list

# Do some optional interactive testing...
$ docker run -it python-2-and-3 /bin/sh
\# python  -V  # Python 2.7.13
\# python2 -V  # Python 2.7.13
\# python3 -V  # Python 3.6.0

\# pip  -V     # pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
\# pip2 -V     # pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
\# pip3 -V     # pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

\# SCRIPT="import platform ; print(platform.python_version())"
\# python  -c "$SCRIPT"  # 2.7.13
\# python2 -c "$SCRIPT"  # 2.7.13
\# python3 -c "$SCRIPT"  # 3.6.0

\# exit
$

python2-and-python3-in-docker's People

Contributors

cclauss avatar mmacvicar-splunk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python2-and-python3-in-docker's Issues

Support for Python 3.7

If possible can you please add the support for Python 3.7 in this Docker image so that we can have Python 2.7. Python 3.6 and Python 3.7 in one image or please let me know how can we add this support for Python 3.7 in this image.

pip3 invalid version

/ # pip -V
pip 18.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
/ # pip2 -V
pip 18.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
/ # pip3 -V
pip 18.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)

pip3 install failed with error code 1

Seems like the python3 'print' syntax was not followed properly, but not sure why.

/ # pip3 --no-cache-dir -v install BeautifulSoup
Collecting BeautifulSoup
1 location(s) to search for versions of BeautifulSoup:

Dependency pip installation script location change

Nice package.
But seems the pip install script provider has reorganized the file structure over the time.

Line 55:
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \

==>

&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/pip/2.7/get-pip.py' \

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.