DOCUMENTATION: https://devguide.python.org/setup/#macos-and-os-x
The python3-setuptools
package provides the easy_install3
command, which we can use to install pip
(not sure why it's not included with Python beta as it normally is with standard releases?)
apt-get update && \
apt-get install -y -q wget && \
apt-get install -y -q build-essential python3-setuptools && \
apt-get build-dep -y -q python3 && \
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0b1.tgz && \
tar xf Python-3.6.0b1.tgz && \
rm Python-3.6.0b1.tgz && \
cd Python-3.6.0b1/ && \
./configure && \
make && \
./python --version
Don't try to move the ./python
executable into /usr/local/bin/
as it won't be able to locate the other libraries/modules it links to. If anyone knows how to solve that issue, then please let me know!
Python looks here for packages:
./python " starts REPL
>>> import sys
>>> print('\n'.join(sys.path))
/usr/local/lib/python36.zip
/Python-3.6.0b1/Lib
/Python-3.6.0b1/build/lib.linux-x86_64-3.6
So if we install Jinja2
we can see where it's installed:
pip install jinja2
/usr/local/lib/python3.4/dist-packages | grep -i jin
Meaning we can now modify the `` environment variable to utilise that package.
export PYTHONPATH="$PYTHONPATH:/usr/local/lib/python3.4/dist-packages"
So now if we open a REPL again with the new Python we can import the package:
./python " starts REPL
>>> import sys
>>> print('\n'.join(sys.path))
/Python-3.6.0b1
/usr/local/lib/python3.4/dist-packages " see it's there <<
/usr/local/lib/python36.zip
/Python-3.6.0b1/Lib
/Python-3.6.0b1/build/lib.linux-x86_64-3.6
import jinja2 " this now works √
The downside to this approach is that the module might not be compatible with the new beta release of Python we've just installed
FROM ubuntu:14.04
ADD . /app
# Set the debconf frontend to Noninteractive
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update && apt-get install -y -q wget curl apt-transport-https lsb-release ca-certificates
# Download and build Python3
# The `python3-setuptools` package provides the `easy_install3` command
RUN apt-get install -y -q build-essential python3-setuptools && apt-get build-dep -y -q python3 && wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0b1.tgz && tar xf Python-3.6.0b1.tgz && rm Python-3.6.0b1.tgz && cd Python-3.6.0b1/ && ./configure && make && ./python --version
RUN easy_install3 pip && pip install jinja2
ENV PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.4/dist-packages"
## References