Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
Jupyter Docker Stacks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Jupyter Docker Stacks
Commits
2485724a
Commit
2485724a
authored
Jul 12, 2016
by
Min RK
Committed by
GitHub
Jul 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #236 from parente/mpl-inline
Default matplotlib to inline backend
parents
9f67ac2e
8ecfc070
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
4 deletions
+69
-4
scipy-notebook/Dockerfile
scipy-notebook/Dockerfile
+14
-4
scipy-notebook/mplimporthook.py
scipy-notebook/mplimporthook.py
+55
-0
No files found.
scipy-notebook/Dockerfile
View file @
2485724a
...
@@ -15,6 +15,8 @@ RUN apt-get update && \
...
@@ -15,6 +15,8 @@ RUN apt-get update && \
USER
$NB_USER
USER
$NB_USER
# Install Python 3 packages
# Install Python 3 packages
# Remove pyqt and qt pulled in for matplotlib since we're only ever going to
# use notebook-friendly backends in these images
RUN
conda
install
--quiet
--yes
\
RUN
conda
install
--quiet
--yes
\
'ipywidgets=5.1*'
\
'ipywidgets=5.1*'
\
'pandas=0.18*'
\
'pandas=0.18*'
\
...
@@ -32,12 +34,15 @@ RUN conda install --quiet --yes \
...
@@ -32,12 +34,15 @@ RUN conda install --quiet --yes \
'dill=0.2*'
\
'dill=0.2*'
\
'numba=0.23*'
\
'numba=0.23*'
\
'bokeh=0.11*'
\
'bokeh=0.11*'
\
'h5py=2.5*'
\
'h5py=2.5*'
&&
\
&&
conda clean
-tipsy
conda remove
--quiet
--yes
--force
qt pyqt
&&
\
conda clean
-tipsy
# Activate ipywidgets extension in the environment that runs the notebook server
# Activate ipywidgets extension in the environment that runs the notebook server
RUN
jupyter nbextension
enable
--py
widgetsnbextension
--sys-prefix
RUN
jupyter nbextension
enable
--py
widgetsnbextension
--sys-prefix
# Install Python 2 packages
# Install Python 2 packages
# Remove pyqt and qt pulled in for matplotlib since we're only ever going to
# use notebook-friendly backends in these images
RUN
conda create
--quiet
--yes
-p
$CONDA_DIR
/envs/python2
python
=
2.7
\
RUN
conda create
--quiet
--yes
-p
$CONDA_DIR
/envs/python2
python
=
2.7
\
'ipython=4.2*'
\
'ipython=4.2*'
\
'ipywidgets=5.1*'
\
'ipywidgets=5.1*'
\
...
@@ -57,12 +62,17 @@ RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 \
...
@@ -57,12 +62,17 @@ RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 \
'numba=0.23*'
\
'numba=0.23*'
\
'bokeh=0.11*'
\
'bokeh=0.11*'
\
'h5py=2.5*'
\
'h5py=2.5*'
\
'pyzmq'
\
'pyzmq'
&&
\
&&
conda clean
-tipsy
conda remove
-n
python2
--quiet
--yes
--force
qt pyqt
&&
\
conda clean
-tipsy
# Add shortcuts to distinguish pip for python2 and python3 envs
# Add shortcuts to distinguish pip for python2 and python3 envs
RUN
ln
-s
$CONDA_DIR
/envs/python2/bin/pip
$CONDA_DIR
/bin/pip2
&&
\
RUN
ln
-s
$CONDA_DIR
/envs/python2/bin/pip
$CONDA_DIR
/bin/pip2
&&
\
ln
-s
$CONDA_DIR
/bin/pip
$CONDA_DIR
/bin/pip3
ln
-s
$CONDA_DIR
/bin/pip
$CONDA_DIR
/bin/pip3
# Configure ipython kernel to use matplotlib inline backend by default
RUN
mkdir
-p
$HOME
/.ipython/profile_default/startup
COPY
mplimporthook.py $HOME/.ipython/profile_default/startup/
USER
root
USER
root
# Install Python 2 kernel spec globally to avoid permission problems when NB_UID
# Install Python 2 kernel spec globally to avoid permission problems when NB_UID
...
...
scipy-notebook/mplimporthook.py
0 → 100644
View file @
2485724a
"""Startup script for IPython kernel.
Installs an import hook to configure the matplotlib backend on the fly.
Originally from @minrk at
https://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py
Repurposed for docker-stacks to address repeat bugs like
https://github.com/jupyter/docker-stacks/issues/235.
"""
import
sys
from
IPython
import
get_ipython
class
MatplotlibFinder
(
object
):
"""Import hook that notices when matplotlib.pyplot or pylab is imported
and tries to configure the matplotlib backend appropriately for the
environment.
"""
_called
=
False
def
find_module
(
self
,
fullname
,
path
=
None
):
if
self
.
_called
:
# already handled
return
if
fullname
not
in
(
'pylab'
,
'matplotlib.pyplot'
):
# not matplotlib
return
# don't call me again
self
.
_called
=
True
try
:
# remove myself from the import hooks
sys
.
meta_path
=
[
loader
for
loader
in
sys
.
meta_path
if
loader
is
not
self
]
except
ValueError
:
pass
ip
=
get_ipython
()
if
ip
is
None
:
# not in an interactive environment
return
if
ip
.
pylab_gui_select
:
# backend already selected
return
if
hasattr
(
ip
,
'kernel'
):
# default to inline in kernel environments
ip
.
enable_matplotlib
(
'inline'
)
else
:
print
(
'enabling matplotlib'
)
ip
.
enable_matplotlib
()
# install the finder immediately
sys
.
meta_path
.
insert
(
0
,
MatplotlibFinder
())
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment