Skip to content

Commit c252160

Browse files
Added assignment markdown with images from path (so it becomes rendered in GitHub); renamed the encoded .md file
1 parent f252685 commit c252160

File tree

8 files changed

+8377
-0
lines changed

8 files changed

+8377
-0
lines changed

01-2020-11-06/assignment_01_img_encoded.md

Lines changed: 8107 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# Assignment 1
2+
3+
1. Please follow the instructions below to install Conda.
4+
2. Get familiar with the Shell-Commands `cd`, `ls`, `pwd` and `mkdir`.
5+
3. Create a Conda environment called `fupy` with the packages `python=3.8` and `jupyterlab` installed.
6+
7+
All information needed should be available below.
8+
9+
If you should have any Questions don't hesitate to state them in our Webex-Teams channel!
10+
11+
# Conda Installation
12+
13+
We use Python throughout the class. We further use some additional packages, installing them individually can be unnecessarily complicated. Hence, we recommend installing Miniconda, which comes with Python (please use 3.x) and the package manager Conda.
14+
15+
_(Note that Conda is a part of the Anaconda distribution. If you are already using the Anaconda distribution you may skip installing Miniconda!)_
16+
17+
## Windows
18+
19+
- Visit [https://docs.conda.io/en/latest/miniconda.html](https://docs.conda.io/en/latest/miniconda.html)
20+
- Download the installer for Python 3.x, for your OS-Architecture (probably `64bit`) and run it.
21+
- You can click on `continue` in each step.
22+
23+
![](img/conda-win-installer.png)
24+
25+
- You should now find two freshly installed programs, in your Start Menu, in the `Anaconda3 (64-bit)` directory.
26+
- Both spawn a terminal window from which the `conda` command is accessible.
27+
- **Please use the `Anaconda Powershell Prompt`** _(instead of the `Anaconda prompt`)_ **, as that one also allows inputting typical commands from the UNIX world (macOS, Linux, etc.).**
28+
29+
![](img/conda-win-prompt.png)
30+
31+
- Weiter unten finden Sie eine kurze Übersicht der verfügbaren Kommandos.
32+
33+
## macOS
34+
35+
- Visit [https://docs.conda.io/en/latest/miniconda.html](https://docs.conda.io/en/latest/miniconda.html)
36+
- Download the Python 3.x **pkg** installer and run it.
37+
- You can click on `continue` in each step.
38+
39+
![](img/conda-macos-installer.png)
40+
41+
- After you completed the installation, with the next start of the Terminal application you will be able to use the `conda` command.
42+
43+
![](img/conda-macos-prompt.png)
44+
45+
## Linux
46+
47+
- For Linux there is unfortunately no graphical installer available, thus you need to use your terminal.
48+
49+
### Download
50+
51+
- Open a terminal window and enter the following command:
52+
53+
```
54+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
55+
```
56+
57+
- In case you don't have `wget` installed, please use the following command instead:
58+
59+
```
60+
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda3-latest-Linux-x86_64.sh
61+
```
62+
63+
### Installation
64+
65+
- Run the following command to start the installation:
66+
67+
```
68+
bash Miniconda3-latest-Linux-x86_64.sh
69+
```
70+
- You will be prompted to press `ENTER`, do that.
71+
- Afterwards the EULA will be displayed. Press `q` to quit reading it.
72+
73+
![](img/conda-linux-agb.png)
74+
75+
- Enter `yes` and confirm with `ENTER` to accept the terms.
76+
- Next you will be asked to specify the installation path, press `ENTER` to use the default one.
77+
- Now the installer asks whether to initialize `miniconda3`. **Enter `yes` and confirm with `ENTER`**
78+
- After you completed the installation, with the next start of a terminal window you will be able to use the `conda` command.
79+
80+
![](img/conda-linux-prompt.png)
81+
82+
## Terminal Cheat Sheet
83+
84+
- Hint: You can paste commands into the terminal using:
85+
- Windows: `CTRL + V`
86+
- macOS: `CMD + V`
87+
- Linux: `CTRL + SHIFT + V`
88+
89+
- Hint: You can autocomplete commands and arguments using `TAB`.
90+
- Hint: You can interrupt command execution using `CTRL + C` (e.g. if Conda gets stuck)
91+
92+
### `ls`
93+
94+
- `ls` lists all files and directories in your current path.
95+
96+
```
97+
(base) aleks@pc$ ls
98+
Desktop Documents Downloads miniconda3 Music Pictures Public Uni Videos
99+
```
100+
101+
### `pwd`
102+
103+
- `pwd` returns your current path. Very useful if you should get lost!
104+
105+
```
106+
(base) aleks@pc$ pwd
107+
/home/aleks
108+
```
109+
110+
### `cd`
111+
112+
- `cd` (change directory) moves you into a specified directory
113+
- `..` states "one directory above". Thus by using `cd ..` you can switch to one directory above.
114+
115+
```
116+
(base) aleks@pc$ ls
117+
Desktop Documents Downloads Music Pictures Public Uni Videos
118+
119+
(base) aleks@pc$ pwd
120+
/home/aleks
121+
122+
(base) aleks@pc$ cd Uni
123+
(base) aleks@pc$ pwd
124+
/home/aleks/Uni
125+
126+
(base) aleks@pc$ cd ..
127+
(base) aleks@pc$ pwd
128+
/home/aleks
129+
```
130+
131+
- When starting a terminal window your path will be set to your **Home-Directory**. Depending on which Operating System you use the path-names will look different.
132+
133+
- Windows (`C:\Users\username`):
134+
135+
```
136+
C:\Users\aleks> pwd
137+
138+
Path
139+
----
140+
C:\Users\aleks
141+
```
142+
143+
- macOS (`/Users/username`):
144+
145+
```
146+
aleks@macOS$ pwd
147+
/Users/aleks
148+
```
149+
150+
- Linux (`/home/username`):
151+
152+
```
153+
aleks@linux$ pwd
154+
/home/aleks
155+
```
156+
157+
- Luckily we can use the same command on each OS to get back to our Home-Directory, i.e. `cd ~` or `cd $HOME`.
158+
159+
```
160+
(base) aleks@pc$ cd aa/bb/cc/dd
161+
(base) aleks@pc$ cd $HOME
162+
(base) aleks@pc$ pwd
163+
/home/aleks
164+
```
165+
166+
### `mkdir`
167+
168+
- `mkdir` stands for _make directory_.
169+
170+
```
171+
aleks@pc$ ls
172+
course_a course_b
173+
174+
aleks@pc$ mkdir abv_dataanalysis_python
175+
aleks@pc$ ls
176+
abv_dataanalysis_python course_a course_b
177+
```
178+
179+
- We suggest creating a folder for each lecture/session, e.g.:
180+
181+
```
182+
aleks@pc$ pwd
183+
/home/aleks/Uni/abv_dataanalysis_python
184+
185+
aleks@pc$ mkdir 01_2020_11_06
186+
```
187+
188+
**WARNING**
189+
190+
- Please make sure to not use spaces when naming files and directories! As the terminal separates arguments between spaces.
191+
192+
```
193+
aleks@pc$ mkdir abv dataanalysis python
194+
aleks@pc$ ls
195+
abv course_a course_b dataanalysis python
196+
```
197+
198+
- We now have created three different directories!
199+
- To `cd` into a directory with spaces in the name, put quotation marks (`"` or `'`) around it
200+
201+
```
202+
aleks@pc$ ls
203+
'dir with spaces' dir_a dir_b
204+
aleks@pc$ cd 'dir with spaces'
205+
aleks@pc$ pwd
206+
/home/aleks/dir with spaces
207+
```
208+
209+
## Conda Cheat Sheet
210+
211+
- As mentioned before Conda allows us to install Python packages easily, while making sure the package versions work well with another.
212+
213+
- Conda also allows us to create virtual environments, i.e. a separated collection of packages.
214+
- The main idea behind that is to save a state in which we are able to run a project. When revisiting a project in the future some packages may have gotten updated, resulting in the project not running at all or in a different manner. Keeping an environment per project allows to restart the project with exactly the packages with which it has worked in the past!
215+
216+
- It is recommended to add the Conda-forge channel to your Conda channels, so we can install community packages:
217+
218+
```
219+
conda config --add channels conda-forge
220+
```
221+
222+
### Creating an Conda environment from scratch
223+
224+
- Once you have installed the Conda package manager, we create a virtual environment by installing Python and all other packages of interest.
225+
226+
- Creating an Conda environment with the name `fupy`:
227+
228+
```
229+
conda create -n fupy
230+
```
231+
232+
- The default Conda environment is `base`, to switch to the newly created environment use `conda activate environment_name`:
233+
234+
```
235+
(base) aleks@pc$ conda activate fupy
236+
(fupy) aleks@pc$
237+
```
238+
- After doing this you can see the changed environment in your Shells' prefix.
239+
240+
### Installing packages
241+
242+
- With the right environment activated you can use `conda install package_1 package_2 [..]` to install packages:
243+
244+
```
245+
(fupy) aleks@pc$ conda install python=3.8 jupyterlab
246+
```
247+
248+
- Conda will automatically install all packages on which the chosen ones depend.
249+
250+
### Deleting environment
251+
252+
```
253+
conda env remove -n environment_name
254+
```
255+
256+
### Creating a conda environment from an environment.yml file
257+
258+
_Note: this will be used later in the lecture and is not part of the assignment_
259+
260+
- Once you have installed the Conda package manager, you may create a virtual environment by instructions within a file (e.g. environment.yml). This allows you to recreate an existing environment from another machine.
261+
262+
- Move to your working directory (use `cd`) and make sure the environment.yml is available (use `ls`) and type one of the following command:
263+
264+
```
265+
conda env create -f environment.yml
266+
```
267+
268+
- Further you may use the Python module `pip` for downloading additional packages from PyPi, the Python Package Index.
269+
270+
- Packaging in Python is still not yet completely free of pain, hence it is recommended to stay - if possible - within one realm (in our case Conda!), when you start to build more complex and sophisticated software.
74.3 KB
Loading
16.5 KB
Loading
46.2 KB
Loading
119 KB
Loading
28.4 KB
Loading
152 KB
Loading

0 commit comments

Comments
 (0)