Skip to content

Commit 848497a

Browse files
committed
simpler install instructions; closes #39
1 parent 0fcbaeb commit 848497a

File tree

1 file changed

+130
-167
lines changed

1 file changed

+130
-167
lines changed

content/installation.md

Lines changed: 130 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,50 @@
33
[this page is adapted from <https://aaltoscicomp.github.io/python-for-scicomp/installation/>]
44

55

6-
## Packages that we will need
7-
8-
In this course we will need **Python 3** and the following Python libraries/packages:
9-
- **jupyterlab**
10-
- **altair**
11-
- pandas (comes with altair)
12-
- vega_datasets (optional)
13-
- numpy (optional)
14-
15-
16-
## How to install Python
17-
18-
We expect you to have a working Python installation with some common libraries.
19-
**We currently recommend Miniforge, which includes the base and packages
20-
through a different, freely usable channel.** You can explore the options in
21-
the tabs below.
6+
## Choosing an installation method
7+
8+
For this course we will install an isolated environment
9+
with following dependencies:
10+
```yaml
11+
name: data-viz
12+
channels:
13+
- conda-forge
14+
dependencies:
15+
- python <= 3.12
16+
- jupyterlab
17+
- altair-all
18+
- vega_datasets
19+
- pandas
20+
- numpy
21+
```
2222
23-
**If you are used to installing Python packages**, you can use your preferred
24-
installation method. However, we recommend to not install the above packages
25-
system-wide and never to install using administrator privileges.
26-
Below we offer several options to install Python and the required packages
27-
from the [environment.yml file](https://github.com/coderefinery/data-visualization-python/blob/main/software/environment.yml).
23+
If you are used to installing packages in Python and know what to do with the
24+
above `environment.yml` file, please follow your own preferred installation
25+
method.
26+
27+
**If you are new to Python or unsure** how to create isolated environments in
28+
Python from files like the `environment.yml` above, please follow the
29+
instructions below.
30+
31+
:::{discussion} There are many choices and we try to suggest a good compromise
32+
There are very many ways to install Python and packages with pros and cons and
33+
in addition there are several operating systems with their own quirks. This
34+
can be a huge challenge for beginners to navigate. It can also difficult for
35+
instructors to give recommendations for something which will work everywhere
36+
and which everybody will like.
37+
38+
Below we will recommend **Miniforge** since it is free, open source, general,
39+
available on all operating systems, and provides a good basis for reproducible
40+
environments. However, it does not provide a graphical user interface during
41+
installation. This means that every time we want to start a JupyterLab session,
42+
we will have to go through the command line.
43+
:::
2844

2945
:::{admonition} Python, conda, anaconda, miniforge, etc?
3046
:class: dropdown
3147

32-
Unfortunately there's a lot of jargon. We'll go over this in the
33-
course but here is a crash course:
48+
Unfortunately there are many options and a lot of jargon.
49+
Here is a crash course:
3450

3551
* **Python** is a programming language very commonly used in
3652
science, it's the topic of this course.
@@ -55,165 +71,112 @@ course but here is a crash course:
5571
the Anaconda channels.
5672
:::
5773

58-
::::{tabs}
59-
:::{group-tab} Miniforge
60-
This is our recommended method - it can be used for any purpose
61-
and makes a strong base for the future.
6274

63-
Follow the [instructions on the miniforge web page](https://github.com/conda-forge/miniforge). This installs
64-
the base, and from here other packages can be installed.
75+
## Installing Python via Miniforge
6576

66-
Miniforge uses the command line - this gives you the most power
67-
but can feel unfamiliar.
68-
:::
77+
Follow the [instructions on the miniforge web page](https://github.com/conda-forge/miniforge). This installs
78+
the base, and from here other packages can be installed.
79+
80+
81+
## Installing and activating the software environment
6982

70-
:::{group-tab} Anaconda
71-
Anaconda is easier to get started with, but may be more limiting
72-
in the future. The Anaconda Navigator provides a graphical
73-
interface to most of what you would need.
83+
First we will start Python in a way that activates conda/mamba. Then we will
84+
install the software environment from [this environment.yml
85+
file](https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml).
7486

75-
The [Anaconda Python distribution](https://docs.continuum.io/anaconda/install/) conveniently packages
76-
most popular libraries, but its license has does not allow large organizations to
77-
use it for free (and has actually been enforced against
78-
universities).
87+
An **environment** is a self-contained set of extra libraries - different
88+
projects can use different environments to not interfere with each other. This
89+
environment will have all of the software needed for this particular course.
7990

80-
Note the license of Anaconda - there were recently issues with
81-
it being used by large universities for free, and this is not
82-
yet fully resolved.
91+
We will call the environment `data-viz`.
92+
93+
::::{tabs}
94+
:::{group-tab} Windows
95+
Use the "Miniforge Prompt" to start Miniforge. This
96+
will set up everything so that ``conda`` and ``mamba`` are
97+
available.
98+
Then type
99+
(without the `$`):
100+
```console
101+
$ mamba env create -n data-viz -f https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml
102+
```
103+
:::
104+
105+
:::{group-tab} Linux / MacOS
106+
Each time you start a new command line terminal,
107+
you can activate Miniforge by running
108+
(without the `$`):
109+
```console
110+
$ source ~/miniforge3/bin/activate
111+
```
112+
113+
This is needed so that
114+
Miniforge is usable wherever you need, but doesn't affect any
115+
other software on your computer (this is not needed if you
116+
choose "Do you wish to update your shell profile to
117+
automatically initialize conda?", but then it will always be
118+
active).
119+
120+
In the second step, we will install the software environment:
121+
```console
122+
$ mamba env create -n data-viz -f https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml
123+
```
83124
:::
84125
::::
85126

86127

87-
## Starting Python
88-
89-
You need to start Python in a way that activates conda/mamba.
90-
91-
::::::{tabs}
92-
:::::{group-tab} Miniforge
93-
::::{tabs}
94-
:::{group-tab} Windows
95-
Windows: Use the "Miniforge Prompt" to start Miniforge. This
96-
will set up everything so that ``conda`` and ``mamba`` are
97-
available.
98-
:::
99-
:::{group-tab} Linux / MacOS
100-
Each time you start a new command line terminal,
101-
you can activate Miniforge by running:
102-
```
103-
$ source ~/miniforge3/bin/activate
104-
```
105-
106-
This is needed so that
107-
Miniforge is usable wherever you need, but doesn't affect any
108-
other software on your computer (this is not needed if you
109-
choose "Do you wish to update your shell profile to
110-
automatically initialize conda?", but then it will always be
111-
active).
112-
:::
113-
::::
114-
:::::
115-
116-
:::::{group-tab} Anaconda
117-
The [Anaconda Navigator](https://docs.anaconda.com/navigator/) provides a convenient
118-
way to access the software. It can be installed from that page.
119-
:::::
120-
::::::
128+
## Starting JupyterLab
121129

130+
Every time we want to start a JupyterLab session,
131+
we will have to go through the command line and first
132+
activate the `data-viz` environment.
122133

123-
## Installing and activating the software environment
134+
::::{tabs}
135+
:::{group-tab} Windows
136+
Start the Miniforge Prompt. Then type
137+
(without the `$`):
138+
```console
139+
$ conda activate data-viz
140+
$ jupyter-lab
141+
```
142+
:::
124143

125-
Once Python and conda/mamba are installed, you can use it to install
126-
an environment. An **environment** is a self-contained set of extra
127-
libraries - different projects can use different environments to not
128-
interfere with each other. This environment will have all of the
129-
software needed for this particular course.
130-
131-
::::::{tabs}
132-
:::::{group-tab} Miniforge
133-
This [environment.yml file](https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml)
134-
contains all packages needed for the course, and can be
135-
installed with. The following command will install an
136-
environment named `data-viz`:
137-
::::{tabs}
138-
:::{group-tab} Windows
139-
```
140-
$ mamba env create -n data-viz -f https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml
141-
```
142-
:::
143-
:::{group-tab} Linux / MacOS
144-
```
145-
$ mamba env create -n data-viz -f https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml
146-
```
147-
:::
148-
::::{tabs}
149-
150-
Each time you start a new command line, you need to activate
151-
miniforge and this environment:
152-
::::{tabs}
153-
:::{group-tab} Windows
154-
Start the Miniforge Prompt. Then run:
155-
```
156-
$ conda activate data-viz
157-
$ jupyter-lab
158-
```
159-
:::
160-
:::{group-tab} Linux / MacOS
161-
```
162-
$ source ~/miniforge3/bin/activate
163-
$ conda activate data-viz
164-
```
165-
:::
166-
::::
167-
:::::
168-
169-
:::::{group-tab} Anaconda
170-
Use the navigator to create a new environment from [this environment.yml
171-
file](https://raw.githubusercontent.com/coderefinery/data-visualization-python/main/software/environment.yml).
172-
You'll have to download it and then [import
173-
it](https://docs.anaconda.com/navigator/tutorials/manage-environments/#importing-an-environment).
174-
175-
When running this course's exercise, make sure the `data-viz` environment is
176-
activated before starting JupyterLab or any code. You need to start
177-
terminals or JupyterLab from the Anaconda Navigator for the `data-viz`
178-
environment to be used.
179-
:::::
180-
::::::
144+
:::{group-tab} Linux / MacOS
145+
Start the terminal and in the terminal, type
146+
(without the `$`):
147+
```console
148+
$ source ~/miniforge3/bin/activate
149+
$ conda activate data-viz
150+
$ jupyter-lab
151+
```
152+
:::
153+
::::
181154

182155

183-
## Starting JupyterLab
156+
## Removing the software environment
157+
158+
::::{tabs}
159+
:::{group-tab} Windows
160+
In the Miniforge Prompt, type
161+
(without the `$`):
162+
```console
163+
$ conda env list
164+
$ conda env remove --name data-viz
165+
$ conda env list
166+
```
167+
:::
184168

185-
We do most of the lessons from JupyterLab (and JupyterLab provides
186-
most of the other tools we need).
187-
188-
::::::{tabs}
189-
:::::{group-tab} Miniforge
190-
::::{tabs}
191-
:::{group-tab} Windows
192-
Start the Miniforge Prompt. Then run:
193-
```
194-
$ conda activate data-viz
195-
$ jupyter-lab
196-
```
197-
:::
198-
:::{group-tab} Linux / MacOS
199-
```
200-
$ source ~/miniforge3/bin/activate
201-
$ conda activate data-viz
202-
$ jupyter-lab
203-
```
204-
:::
205-
::::
206-
:::::
207-
208-
:::::{group-tab} Anaconda
209-
If you install the full Anaconda distribution, this will be
210-
available and can be started either through Anaconda Navigator
211-
or command line.
212-
213-
Make sure the `data-viz` environment is selected and
214-
you can start JupyterLab.
215-
:::::
216-
::::::
169+
:::{group-tab} Linux / MacOS
170+
In the terminal, type
171+
(without the `$`):
172+
```console
173+
$ source ~/miniforge3/bin/activate
174+
$ conda env list
175+
$ conda env remove --name data-viz
176+
$ conda env list
177+
```
178+
:::
179+
::::
217180

218181

219182
## How to verify your installation

0 commit comments

Comments
 (0)