Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr-ressources
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Learning Lab
mooc-rr-ressources
Commits
0893b72e
Commit
0893b72e
authored
Feb 19, 2019
by
Laurence Farhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modif du titre de la doc sur Jupiter + génération du .md
parent
ee77013c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
433 additions
and
143 deletions
+433
-143
emacs_orgmode.md
module2/ressources/emacs_orgmode.md
+127
-142
jupyter.md
module2/ressources/jupyter.md
+305
-0
jupyter.org
module2/ressources/jupyter.org
+1
-1
No files found.
module2/ressources/emacs_orgmode.md
View file @
0893b72e
...
...
@@ -3,51 +3,49 @@ configuration* and *A stub of replicable article* explain how to set up
emacs/org-mode for this MOOC. These are very important sections in the
context of this MOOC.
**
These sections are illustrated in two out of the
[
three video tutorials of this
sequence](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
1bis
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4),
sequence](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
2
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4),
and
** **
which you really should follow carefully
**. **
Otherwise, you may
have trouble doing the exercises later on
**
. Likewise, I strongly
encourage you to watch the
[
"emacs and git" video tutorial available at
the same
place](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
1bis
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4).
place](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
2
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4).
The next section provides information on how to install emacs.
The next section provides information on how to install
emacs.
Table of Contents
=================
# Table of Contents <span class="tag" data-tag-name="TOC"><span class="smallcaps">TOC</span></span>
-
[
Installing emacs, org-mode, ess, and
-
[
Installing emacs, org-mode, ess, and
auctex.](#installing-emacs-org-mode-ess-and-auctex)
-
[
Linux (Debian, Ubuntu)
](
#linux-debian-ubuntu
)
-
[
macOS
](
#macos
)
-
[
Windows
](
#windows
)
-
[
All platforms: pretty code in HTML
-
[
Linux (Debian, Ubuntu)
](
#linux-debian-ubuntu
)
-
[
macOS
](
#macos
)
-
[
Windows
](
#windows
)
-
[
All platforms: pretty code in HTML
export](#all-platforms-pretty-code-in-html-export)
-
[
A simple "
*reproducible research*
" emacs configuration
-
[
A simple "
*reproducible research*
" emacs configuration
](#a-simple-reproducible-research-emacs-configuration-)
-
[
Step 0: Backup and download our
-
[
Step 0: Backup and download our
configuration](#step-0-backup-and-download-our-configuration)
-
[
Step 1: Prepare your journal
](
#step-1-prepare-your-journal
)
-
[
Step 2: Set up Emacs
-
[
Step 1: Prepare your journal
](
#step-1-prepare-your-journal
)
-
[
Step 2: Set up Emacs
configuration](#step-2-set-up-emacs-configuration)
-
[
Step 3: Adapt the configuration to your specific needs if
-
[
Step 3: Adapt the configuration to your specific needs if
required](#step-3-adapt-the-configuration-to-your-specific-needs-if-required)
-
[
Step 4: Check whether the installation is working or
-
[
Step 4: Check whether the installation is working or
not](#step-4-check-whether-the-installation-is-working-or-not)
-
[
Step 5: Open and play with your
-
[
Step 5: Open and play with your
journal:](#step-5-open-and-play-with-your-journal)
-
[
A stub of a replicable article
](
#a-stub-of-a-replicable-article
)
-
[
Emacs tips and tricks
](
#emacs-tips-and-tricks
)
-
[
Cheat-sheets
](
#cheat-sheets
)
-
[
Video tutorials
](
#video-tutorials
)
-
[
Additional useful emacs
-
[
A stub of a replicable article
](
#a-stub-of-a-replicable-article
)
-
[
Emacs tips and tricks
](
#emacs-tips-and-tricks
)
-
[
Cheat-sheets
](
#cheat-sheets
)
-
[
Video tutorials
](
#video-tutorials
)
-
[
Additional useful emacs
packages](#additional-useful-emacs-packages)
-
[
Other resources
](
#other-resources
)
-
[
Other resources
](
#other-resources
)
Installing emacs, org-mode, ess, and auctex.
============================================
# Installing emacs, org-mode, ess, and auctex.
Linux (Debian, Ubuntu)
----------------------
## Linux (Debian, Ubuntu)
We provide here only instructions for Debian-based distributions. Feel
free to contribute to this document to provide up-to-date information
...
...
@@ -56,63 +54,63 @@ for other distributions (e.g.n redhat, fedora).
Today, the stable versions of the most common distributions provide
recent enough versions of emacs and org-mode:
-
Debian (stretch) ships with
[
emacs
25.
1](https://packages.debian.org/stretch/emacs25) and
[
org-mode
9.
0.3](https://packages.debian.org/stretch/org-mode)
-
Ubuntu (bionic 18.04) ships with
[
emacs
25.
2](https://packages.ubuntu.com/bionic/emacs25) and
[
org-mode
9.
1.6](https://packages.ubuntu.com/bionic/org-mode)
-
Ubuntu (artful 17.04) ships with
[
emacs
25.
2](https://packages.ubuntu.com/artful/emacs25) and
[
org-mode
9.
0.9](https://packages.ubuntu.com/artful/org-mode)
-
Debian (stretch) ships with
[
emacs 25.1
](
https://packages.debian.org/stretch/emacs25
)
and
[
org-mode
9.0.3
](
https://packages.debian.org/stretch/org-mode
)
-
Ubuntu (bionic 18.04) ships with
[
emacs 25.2
](
https://packages.ubuntu.com/bionic/emacs25
)
and
[
org-mode
9.1.6
](
https://packages.ubuntu.com/bionic/org-mode
)
-
Ubuntu (artful 17.04) ships with
[
emacs 25.2
](
https://packages.ubuntu.com/artful/emacs25
)
and
[
org-mode
9.0.9
](
https://packages.ubuntu.com/artful/org-mode
)
If your distribution is older than this, well, it may be a good time for
upgrading
...
upgrading
…
Simply run (as root):
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
```
bash
apt-get update
;
apt-get
install
emacs25 org-mode ess r-base auctex
```
Then make sure you have a sufficiently recent version of emacs.
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
```
bash
emacs
--version
2>&1 |
head
-n
1
```
```
{.example}
```
example
GNU Emacs 25.2.2
```
Likewise, you'll want to check you have a recent version of org-mode:
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
```
bash
emacs
-batch
--funcall
"org-version"
2>&1 |
grep
version
```
```
{.example}
```
example
Org mode version 9.1.11 (9.1.11-dist @ /usr/share/emacs/25.2/site-lisp/elpa/org-9.1.11/)
```
The version numbers you get will depend on the distribution you are
running.
**You really want to make sure you do not rely on org-mode 8**
,
which is now deprecated.
running.
<span
class=
"underline"
>
You really want to make sure you do not
rely on org-mode 8
</span>
,
which is now deprecated.
macOS
-----
## macOS
**Note:**
macOS comes with a prehistoric command-line-only version of
Emacs located at
`/usr/bin/emacs`
. It's best to forget about it.
-
**Option 1**
: Install the
`.dmg`
file from
[
Vincent
-
**Option 1**
: Install the
`.dmg`
file from
[
Vincent
Goulet](http://vgoulet.act.ulaval.ca/):
[
<https://vigou3.gitlab.io/emacs-modified-macos/>
](
https://vigou3.gitlab.io/emacs-modified-macos/
)
.
It ships with recent versions:
-
Emacs 26.1
-
Org-mode 9.1.13
-
ESS 17.11
<https://vigou3.gitlab.io/emacs-modified-macos/>
. It ships with
recent versions:
-
Emacs 26.1
-
Org-mode 9.1.13
-
ESS 17.11
If you install this version of Emacs, or in fact any other version
of Emacs distributed as a clickable application in a
`.dmg`
file,
you must type the full path to the executable if you want to run
...
...
@@ -120,10 +118,10 @@ Emacs located at `/usr/bin/emacs`. It's best to forget about it.
at
`/Applications/Emacs.app`
, then the executable is at
`/Applications/Emacs.app/Contents/MacOS/Emacs`
-
**Option 2**
: If you use
[
Homebrew
](
https://docs.brew.sh/
)
, do the
-
**Option 2**
: If you use
[
Homebrew
](
https://docs.brew.sh/
)
, do the
following:
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
```
bash
brew update
brew
install
emacs
--with-cocoa
brew linkapps emacs
...
...
@@ -133,31 +131,30 @@ Emacs located at `/usr/bin/emacs`. It's best to forget about it.
brew tap brewsci/science
brew
install
ess
```
This provides an
`
emacs
`
command
for
use from the
command
line, plus
a clickable application at
`
Cellar/emacs/26.1_1/Emacs.app
`
inside
your Homebrew directory. If you installed Homebrew at the default
location
`
/usr/local
`
,
then
this is
`
/usr/local/Cellar/emacs/26.1_1/Emacs.app
`
.
If you installed
Homebrew on an account with administrator privileges, you can add
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
```
bash
brew linkapps emacs
```
in
order to make Emacs accessible directly from
`
/Applications
`
.
Windows
-------
## Windows
Install the
`
.exe
`
file from
[
Vincent
Goulet]
(
http://vgoulet.act.ulaval.ca/
)
:
[
<https://vigou3.gitlab.io/emacs-modified-windows/>
](
https://vigou3.gitlab.io/emacs-modified-windows/
)
.
It ships with recent
versions:
<https://vigou3.gitlab.io/emacs-modified-windows/>. It ships with recent
versions:
-
Emacs 26.1
-
Org-mode 9.1.13
-
ESS 17.11
-
Emacs 26.1
-
Org-mode 9.1.13
-
ESS 17.11
### Directory naming conventions
...
...
@@ -185,7 +182,7 @@ explained
Open an DOS console and
type
the following
command
:
```
{.shell .rundoc-block rundoc-language="shell" rundoc-results="output" rundoc-exports="both"}
```
shell
python -m pip install -U matplotlib
```
...
...
@@ -195,7 +192,7 @@ Then you will want to deactivate interactive plots in matplotlib. To
this end, you first need to know where the matplotlib configuration is
located. Open a python console the type the following code:
```
{.python .rundoc-block rundoc-language="python" rundoc-results="output" rundoc-exports="both"}
```
python
import matplotlib
matplotlib.matplotlib_fname()
```
...
...
@@ -205,23 +202,22 @@ matplotlib.matplotlib_fname()
Open the `matplotlibrc` file and modify the line starting with `backend`
to make it `backend : Agg`.
All platforms: pretty code in HTML export
-----------------------------------------
## All platforms: pretty code in HTML export
To have code pretty printing when exporting to HTML, you should install
the `htmlize` package, which is done by opening emacs and typing the
following command:
following
command:
```
{.example}
```
example
M-x package-install RET htmlize RET # where M-x means pressing the "Esc" key then the "x" key
```
A simple "*reproducible research*" emacs configuration
======================================================
# A simple "*reproducible research*" emacs configuration
This section is illustrated in a [video
tutorial](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
1bis
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4)
(
/"Mise en place Emacs/Orgmode"/
in French). Watching it before
tutorial](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
2
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4)
(
*"Mise en place Emacs/Orgmode"*
in French). Watching it before
following the instructions given in this section may help.
Emacs comes with very basic default configuration and it appears like
...
...
@@ -235,8 +231,7 @@ references). In the context of this MOOC, we propose you a relatively
minimalist one that is rather "*reproducible research*" oriented by
adding a few org-mode specific configurations.
Step 0: Backup and download our configuration
---------------------------------------------
## Step 0: Backup and download our configuration
The procedure we propose will wipe your already existing custom Emacs
configuration if you have one. **You should thus beforehand make a
...
...
@@ -244,11 +239,11 @@ backup** of `~/.emacs` and of `~/.emacs.d/init.el` (if these files
exist).
Then download [this
archive](https://
app-learninglab.inria.fr/gitlab/learning-lab/mooc-rr-ressources/raw/master/module2/
ressources/rr_org_archive.tgz)
archive](https://
gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-
ressources/rr_org_archive.tgz)
and uncompress it. It contains the following files and we will refer to
them in the following:
```
{.example}
```
example
rr_org/init.el
rr_org/journal.org
```
...
...
@@ -256,12 +251,11 @@ rr_org/journal.org
Alternatively, [the files you are looking for are available
here](rr_org/).
Step 1: Prepare your journal
----------------------------
## Step 1: Prepare your journal
Create an `org/` directory in the top of your home:
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
```
bash
mkdir -p ~/org/
```
...
...
@@ -269,11 +263,10 @@ Then copy `rr_org/journal.org` file in your `~/org/` directory. This
file will be your laboratory notebook and all the notes you will capture
with `C-c c` will go automatically go in this file. The first entry of
this notebook is populated with [many Emacs
shortcuts](https://
app-learninglab.inria.fr/gitlab/learning-lab
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org)
shortcuts](https://
gitlab.inria.fr/learninglab/mooc-rr
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org)
that you should give a try.
Step 2: Set up Emacs configuration
----------------------------------
## Step 2: Set up Emacs configuration
Copy `rr_org/init.el` in your `~/.emacs.d/` directory.
...
...
@@ -281,8 +274,7 @@ Alternatively, if you do not want to mess with your already existing
emacs configuration, you may launch emacs with this specific
configuration with the following command: `emacs -q -l rr_org/init.el`.
Step 3: Adapt the configuration to your specific needs if required
------------------------------------------------------------------
## Step 3: Adapt the configuration to your specific needs if required
There are two situations in which it might be necessary to modify
`init.el`:
...
...
@@ -291,22 +283,20 @@ There are two situations in which it might be necessary to modify
sites (HTTP(S) protocol).
2. You have multiple installations of Python or R on your computer, or
they are in unusual places and not fully configured. If you can run
- "python3" and "R" under Linux and macOS
- "Python" and "R" under Windows
- "python3" and "R" under Linux and macOS
- "Python" and "R" under Windows
in a terminal without getting an error message, then you should not
have to do anything.
If you do have to modify `init.el`, check the comments at the beginning
of the file for instructions.
Step 4: Check whether the installation is working or not
--------------------------------------------------------
## Step 4: Check whether the installation is working or not
Open a new instance of Emacs and open a `foo.org` file. Copy the
following lines in this file:
```
{.example}
```
example
#+begin_src shell :session foo :results output :exports both
ls -la # or dir under windows
#+end_src
...
...
@@ -323,22 +313,20 @@ In the video, we already have demonstrated the main features and
shortcuts of emacs/org-mode that will help you maintain a document and
benefit from literate programming. The list of features and shortcuts is
demonstrated in the [first entry of your
labbook](https://
app-learninglab.inria.fr/gitlab/learning-lab
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org).
labbook](https://
gitlab.inria.fr/learninglab/mooc-rr
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org).
Step 5: Open and play with your journal:
----------------------------------------
## Step 5: Open and play with your journal:
In step 1, you were told to create an journal in `~org/journal.org`.
First you probably want to make sure this file is stored in a version
control system like git. We leave it up to you to set this up but if you
have any trouble, feel free to ask on the FUN forums.
A stub of a replicable article
==============================
# A stub of a replicable article
This section is illustrated in a [video
tutorial](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
1bis
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4)
(
/"Écrire un article réplicable avec Emacs/Orgmode"/
in French).
tutorial](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
2
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4)
(
*"Écrire un article réplicable avec Emacs/Orgmode"*
in French).
Watching it before following the instructions given in this section may
help.
...
...
@@ -348,42 +336,45 @@ not be able to generate this document. When being compiled, the article
downloads the corresponding LaTeX packages so you also need to have a
working `wget` command (alternatively, it uses `curl`). Once downloaded,
you may still read the source
(
[article.org](https://app-learninglab.inria.fr/gitlab/learning-lab/mooc-rr-ressources/blob/master/module2/ressources/replicable_article/article.org)
)
(
<https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/module2/ressources/replicable_article/article.org>
)
and understand how it works though.
Download the following
[archive](https://
app-learninglab.inria.fr/gitlab/learning-lab/mooc-rr-ressources/raw/master/module2/
ressources/replicable_article.tgz),
[archive](https://
gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-
ressources/replicable_article.tgz),
uncompress it and simply `make` to generate the article. You should then
be able to open the [resulting
article](https://app-learninglab.inria.fr/gitlab/learning-lab/mooc-rr-ressources/blob/master/module2/ressources/replicable_article/article.pdf).
This is summarized in the following command:
article](https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/module2/ressources/replicable_article/article.pdf).
This is summarized in the following
command:
```
{.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
wget --no-check-certificate -O replicable_article.tgz https://
app-learninglab.inria.fr/gitlab/learning-lab/mooc-rr-ressources/raw/master/module2/
ressources/replicable_article.tgz
```
bash
wget --no-check-certificate -O replicable_article.tgz https://
gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-
ressources/replicable_article.tgz
tar zxf replicable_article.tgz; cd replicable_article; make ; evince article.pdf
```
**Possible issues**:
-
If the `
make
` command fails (especially on Mac), it may be because
-
If the `make` command fails (especially on Mac), it may be because
Emacs or something else is not correctly installed. In that case,
open the article directly with the following command:
``` {.bash .rundoc-block rundoc-language="sh" rundoc-results="output" rundoc-exports="both"}
open the article directly with the following
command:
``` bash
emacs -q --eval "(setq enable-local-eval t)" --eval "(setq enable-local-variables t)" article.org
```
and export it to pdf with the following shortcut: `C-c C-e l o`
- If it still doesn't work and emacs complains about not finding ESS,
- If it still doesn't work and emacs complains about not finding ESS,
it may be because you installed ESS in your home instead of
system-wide. In that case, try to remove the `-q` in the previous
command line to load your personal emacs configuration.
Finally, when you'll be tired of always re-executing all the source code
when exporting, just look for the following line in
[article.org](https://
app-learninglab.inria.fr/gitlab/learning-lab
/mooc-rr-ressources/blob/master/module2/ressources/replicable_article/article.org):
[article.org](https://
gitlab.inria.fr/learninglab/mooc-rr
/mooc-rr-ressources/blob/master/module2/ressources/replicable_article/article.org):
```
{.example}
```
example
# #+PROPERTY: header-args :eval never-export
```
...
...
@@ -391,11 +382,9 @@ If you remove the `# ` in the beginning of the line, it will not be a
comment anymore and will indicate org-mode to stop evaluating every
chunk of code when exporting.
Emacs tips and tricks
=====================
# Emacs tips and tricks
Cheat-sheets
------------
## Cheat-sheets
Learning Emacs and Org-Mode can be difficult as there is an inordinate
amount of shortcuts. Many people have thus come up with cheat-sheats.
...
...
@@ -403,37 +392,35 @@ Here is a selection in case it helps:
### Emacs
-
[Common and step-by-step Emacs shortcuts for our *reproducible
-
[
Common and step-by-step Emacs shortcuts for our
*
reproducible
research
*
configuration](https://
app-learninglab.inria.fr/gitlab/learning-lab
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org)
-
[The official GNU emacs
configuration](https://
gitlab.inria.fr/learninglab/mooc-rr
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org)
-
[
The official GNU emacs
refcard](https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf)
- Two graphical cheat-sheats by Sacha Chua o
n

and on
.
-
Two graphical cheat-sheats by Sacha Chua on
[
how to lear
n
Emacs
](http://sachachua.com/blog/wp-content/uploads/2013/05/How-to-Learn-Emacs-v2-Large.png)
and on
[
how to learn Emacs
shortcuts
](http://sachachua.com/blog/wp-content/uploads/2013/08/20130830-Emacs-Newbie-How-to-Learn-Emacs-Keyboard-Shortcuts.png).
### Org-mode
-
[Common and step-by-step org-mode shortcuts for our *reproducible
-
[
Common and step-by-step org-mode shortcuts for our
*
reproducible
research
*
configuration](https://
app-learninglab.inria.fr/gitlab/learning-lab
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org)
-
[The official org-mode
configuration](https://
gitlab.inria.fr/learninglab/mooc-rr
/mooc-rr-ressources/blob/master/module2/ressources/rr_org/journal.org)
-
[
The official org-mode
refcard](https://orgmode.org/worg/orgcard.html)
-
[The official description of the org-mode
-
[
The official description of the org-mode
syntax](https://orgmode.org/worg/dev/org-syntax.html) and a
[
relatively concise description of the org-mode
syntax](https://gist.github.com/hoeltgman/3825415).
Video tutorials
---------------
## Video tutorials
For those of you who prefer video explanations, here is a
[
Youtube
channel with many step by step emacs
tutorials](https://www.youtube.com/playlist?list=PL9KxKa8NpFxIcNQa9js7dQQIHc81b0-Xg).
Additional useful emacs packages
--------------------------------
## Additional useful emacs packages
### Company-mode
...
...
@@ -441,13 +428,13 @@ Additional useful emacs packages
framework for Emacs. It allows to have smart completion in emacs for the
most common languages. If you feel this is needed, you should follow the
instructions from the official Web page:
[<http://company-mode.github.io/>](http://company-mode.github.io/)
<http://company-mode.github.io/>
### Magit
[
Magit
](
https://magit.vc/
)
is an Emacs interface for Git. Its usage is
briefly illustrated in the context of this MOOC in a
[
video
tutorial](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
1bis
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4)
tutorial](https://www.fun-mooc.fr/courses/course-v1:inria+41016+session0
2
/jump_to_id/9cfc7500f0ef46d288d2317ec7b037b4)
("
*Utilisation Emacs/git*
" in French).
It is very powerful and we use it on a daily basis but you should
...
...
@@ -458,10 +445,8 @@ walk-through](https://magit.vc/screenshots/) or [this really short
the previous "
*reproducible research*
" emacs configuration, you can
easily invoke magit by using
`C-x g`
.
Other resources
---------------
## Other resources
-
[
The compact Org-mode Guide
](
https://orgmode.org/orgguide.pdf
)
-
[
Many examples illustrating the use of different languages in
-
[
The compact Org-mode Guide
](
https://orgmode.org/orgguide.pdf
)
-
[
Many examples illustrating the use of different languages in
org-mode](https://github.com/dfeich/org-babel-examples)
module2/ressources/jupyter.md
0 → 100644
View file @
0893b72e
# 1\. Jupyter tips and tricks
The following
[
webpage
](
https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
)
lists several Jupyter tricks (in particular, it illustrates many
`IPython magic`
commands) that should improve your efficiency (note that
this blog post is about two years old so some of the tricks may have
been integrated in the default behavior of Jupyter now).
## Creating or importing a notebook
Using the Jupyter environment we deployed for this MOOC will allow to
easily access any file from your default GitLab project. There are
situations however where you may want to play with other notebooks.
-
Adding a brand new notebook in a given directory
Simply follow the following steps:
1.
From the menu:
`File -> Open`
. You're now in the Jupyter file
manager.
2.
Navigate to the directory where you want your notebook to be
created.
3.
Then from the top right button:
`New -> Notebook: Python 3`
.
4.
Give your notebook a name from the menu:
`File -> Rename`
.
N.B.: If you create a file by doing
`File -> New Notebook ->
Python 3`
, the new notebook will be created in the current
directory. Moving it afterward is possible but a bit cumbersome
(you'll have to go through the Jupyter file manager by following
the menu
`File -> Open`
, then select it,
`Shut`
it
`down`
, and
`Move`
and/or
`Rename`
).
-
Importing an already existing notebook
If your notebook is already in your GitLab project, then simply
synchronize by using the
`Git pull`
button and use the
`File ->
Open`
menu. Otherwise, imagine, you want to import the
[
following
notebook](https://app-learninglab.inria.fr/gitlab/moocrr-session1/moocrr-reproducibility-study/blob/master/src/Python3/challenger.ipynb)
from someone else's repository to re-execute it.
1.
Download the file on your computer. E.g., for this
[
GitLab
hosted
notebook](https://app-learninglab.inria.fr/gitlab/moocrr-session1/moocrr-reproducibility-study/blob/master/src/Python3/challenger.ipynb),
click on
`Open raw`
(a small
`</>`
within a document icon) and
save (
`Ctrl-S`
on most browsers) the content (a long Json text
file).
2.
Open the Jupyter file manager from the menu
`File -> Open`
and
navigate to the directory where you want to upload your
notebook.
3.
Then from the top right button,
`Upload`
the previously
downloaded notebook and confirm the upload.
4.
Open the freshly uploaded notebook through the Jupyter file
manager.
## Running R and Python in the same notebook
`rpy2`
package allows to use both languages in the same notebook by:
1.
Loading
`rpy2`
:
```
python
%
load_ext
rpy2
.
ipython
``
`
2.
Using
the
`%R`
Ipython
magic
:
``
`
python
%%
R
summary
(
cars
)
``
`
Python
objects
can
then
even
be
passed
to
R
as
follows
(
assuming
`df`
is
a
pandas
dataframe
):
``
`
python
%%
R
-
i
df
plot
(
df
)
``
`
Note
that
this
`%%R`
notation
indicates
that
R
should
be
used
for
the
whole
cell
but
an
other
possibility
is
to
use
`%R`
to
have
a
single
line
of
R
within
a
python
cell
.
## Other languages
Jupyter
is
not
limited
to
Pytyhon
and
R
.
Many
other
languages
are
available
:
<
https
:
//
github
.
com
/
jupyter
/
jupyter
/
wiki
/
Jupyter
-
kernels
>
,
including
non
-
free
languages
like
SAS
,
Mathematica
,
Matlab
…
Note
that
the
maturity
of
these
kernels
differs
widely
.
None
of
these
other
languages
have
been
deployed
in
the
context
of
our
MOOC
but
you
may
want
to
read
the
next
sections
to
learn
how
to
set
up
your
own
Jupyter
on
your
computer
and
benefit
from
these
extensions
.
Since
the
question
was
asked
several
times
,
if
you
really
need
to
stay
with
SAS
,
you
should
know
that
SAS
can
be
used
within
Jupyter
using
either
the
[
Python
SASKernel
](
https
:
//
sassoftware
.
github
.
io
/
sas_kernel
/
)
or
the
[
Python
SASPy
](
https
:
//
sassoftware
.
github
.
io
/
saspy
/
)
package
(
step
by
step
explanations
about
this
are
given
[
here
](
https
:
//
gitlab
.
inria
.
fr
/
learninglab
/
mooc
-
rr
/
mooc
-
rr
-
ressources
/
blob
/
master
/
documents
/
tuto_jupyter_windows
/
tuto_jupyter_windows
.
md
))
.
Since
proprietary
software
such
as
SAS
cannot
easily
be
inspected
,
we
discourage
its
use
as
it
hinders
reproducibility
by
essence
.
But
perfection
does
not
exist
anyway
and
using
Jupyter
literate
programming
approach
allied
with
systematic
control
version
and
environment
control
will
certainly
help
anyway
.
# 2\. Installing and configuring Jupyter on your computer
In
this
section
,
we
explain
how
to
set
up
a
Jupyter
environment
on
your
own
computer
similar
to
the
one
deployed
for
this
MOOC
.
Note
that
Jupyter
notebooks
are
only
a
small
part
of
the
picture
and
that
Jupyter
is
now
part
of
a
bigger
project
:
[
JupyterLab
](
https
:
//
blog
.
jupyter
.
org
/
jupyterlab
-
is
-
ready
-
for
-
users
-
5
a6f039b8906
),
which
allows
you
to
mix
various
components
(
including
notebooks
)
in
your
browser
.
In
the
context
of
this
MOOC
,
our
time
frame
was
too
short
to
benefit
from
JupyterLab
which
was
still
under
active
development
.
You
may
,
however
,
prefer
JupyterLab
when
doing
an
installation
on
your
own
computer
.
## 2.1 Installing Jupyter
Follow
these
instructions
if
you
wish
to
have
a
Jupyter
environment
on
your
own
computer
similar
to
the
one
we
set
up
for
this
MOOC
.
First
,
download
and
install
the
[
latest
version
of
Miniconda
](
https
:
//
conda
.
io
/
miniconda
.
html
)
.
We
use
Miniconda
version
`4.5.4`
and
Python
version
`3.6`
on
our
server
.
Miniconda
is
a
light
version
of
Anaconda
,
which
includes
Python
,
the
Jupyter
Notebook
,
and
other
commonly
used
packages
for
scientific
computing
and
data
science
.
Then
download
the
[
mooc
<
sub
>
rr
</
sub
>
environment
file
](
https
:
//
gist
.
github
.
com
/
brospars
/
4671
d9013f0d99e1c961482dab533c57
)
and
create
the
environment
using
conda
:
```
shell
conda env create -f environment.yml
# Windows activate the environment
activate mooc_rr
# Linux and MacOS activate the environment
source activate mooc_rr
# Linux, MacOS and Windows: launch the notebook
jupyter notebook
```
## 2.2 Making sure Jupyter allows you to use R
The environment described in the last section should include R, but if
you proceeded otherwise and only have Python available in Jupyter, you
may want to read the following
section.
### • Installing [IRKernel](https://github.com/IRkernel/IRkernel) (R package)
Do the following in R console:
Install the `devtools` package:
```
r
install.packages('devtools',dep=TRUE)
```
Define a proxy if needed:
```
r
library(httr)
set_config(use_proxy(url="proxy", port=80, username="username", password="password"))
```
Install the `IRkernel` package:
```
r
devtools::install_github('IRkernel/IRkernel')
IRkernel::installspec() # to register the kernel in the current R installation
```
### • Installing rpy2 (Python package)
On Linux, the rpy2 package is available in standard distributions
```
shell
sudo apt-get install python3-rpy2 python3-tzlocal
```
An alternative (not really recommended if the first one is available)
consists in going through the python package manager with
```
python
pip3 install rpy2
```
**Windows**
Download the `rpy2` [binary
file](https://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2) by choosing the
right operating system.
Open a DOS console and type the following
command:
```
shell
python -m pip install rpy2‑2.9.4‑cp37‑cp37m‑win_amd64.whl # adapt filename
```
Install also `tzlocal`:
```
shell
python -m pip install tzlocal
```
## 2.3 Additional tips
### • Exporting a notebook
Here is what we had to install on a recent Debian computer to make sure
the notebook export via LaTeX works:
```
shell
sudo apt-get install texlive-xetex wkhtmltopdf
```
Obviously, you can convert to html or pdf using the using the `File >
Download as > HTML` (or `PDF`) menu option. This can also be done from
the command line with the following command:
```
bash
ipython3 nbconvert --to pdf Untitled.ipynb
```
If you want to use a specific style, then the `nbconvert` exporter
should be customized. This is discussed and demoed
[here](http://markus-beuckelmann.de/blog/customizing-nbconvert-pdf.html).
We encourage you to simply read the [doc of
nbconvert](https://nbconvert.readthedocs.io/en/latest/).
Instead of going directly through LaTeX and playing too much with the
`nbconvert` exporter, an other option consists in exporting to Markdown
and playing with [pandoc](https://pandoc.org/). Both approaches work,
it's rather a matter of taste.
**Windows**
Download and install MiKTeX from the [MiKTeX
webpage](https://miktex.org/download) by choosing the right operating
system. You will be prompted to install some specific packages when
exporting to pdf.
### • Improving notebook readability
Here are a few extensions that can ease your life:
- [Code
folding](https://stackoverflow.com/questions/33159518/collapse-cell-in-jupyter-notebook)
to improve readability when browsing the notebook.
```
shell
pip3 install jupyter_contrib_nbextensions
# jupyter contrib nbextension install --user # not done yet
```
- [Hiding code](https://github.com/kirbs-/hide_code) to improve
readability when exporting.
```
bash
sudo pip3 install hide_code
sudo jupyter-nbextension install --py hide_code
jupyter-nbextension enable --py hide_code
jupyter-serverextension enable --py hide_code
```
### • Interacting with GitLab and GitHub
To ease your experience, we added pull/push buttons that allow you to
commit and sync with GitLab. This development was specific to the MOOC
but inspired from a previous
[
proof of
concept](https://github.com/Lab41/sunny-side-up). We have recently
discovered that someone else developed about at the same time a
[
rather
generic version of this Jupyter
plugin](https://github.com/sat28/githubcommit). Otherwise, remember that
it is very easy to insert a shell cell in Jupyter in which you can
easily issue git commands. This is how we work most of the time.
This being said, you may have noticed that Jupyter keeps a perfect track
of the sequence in which cells have been run by updating the "output
index". This is a very good property from the reproducibility point of
view but depending on your usage, you may find it a bit painful when
committing. Some people have thus developed
[
specific git
hooks](https://gist.github.com/pbugnion/ea2797393033b54674af) to ignore
these numbers when committing Jupyter notebooks. There is a long an
interesting discussion about various options on
[
StackOverflow
](
https://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control
)
.
For those who use
[
JupyterLab
](
https://blog.jupyter.org/jupyterlab-is-ready-for-users-5a6f039b8906
)
rather than the plain Jupyter, a specific
[
JupyterLab git
plugin](https://github.com/jupyterlab/jupyterlab-git) has been developed
to offer a nice version control experience.
module2/ressources/jupyter.org
View file @
0893b72e
# -*- mode: org -*-
#+TITLE: Jupyter
#+TITLE: Jupyter
: tips and tricks, Installing and configuring
#+AUTHOR: Arnaud Legrand, Benoit Rospars, Konrad Hinsen
#+DATE: June, 2018
#+STARTUP: overview indent
...
...
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