You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notebooks/installing_Python.md
+18-14Lines changed: 18 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,9 @@
2
2
3
3
We will use a free environment management system called **conda** to install Python and the necessary scientific libraries for the course. The conda management system allows to install, run, and update Python packages while ensuring compatibility between different package versions on your machine. It also allows to efficiently manage Python environments, which are essentially independent Python installations. More details on this later.
4
4
5
-
## Install Python, Python scientific libraries, and Jupyter Lab using Miniconda
5
+
[TOC]
6
+
7
+
## 1. Install Python, scientific libraries, and Jupyter Lab using Miniconda
6
8
7
9
For this course, we will use Miniconda which allows us to manage Python packages through a console with a minimal installation (don't be scared, it's simpler than it sounds).
8
10
@@ -66,7 +68,7 @@ We will learn how to use Jupyter Lab properly during the course.
66
68
> This is a cross-platform desktop application for Jupyter Lab. It is exactly the same application that opens in the browser, but in an encapsulated application. You can find the user guide at the following link https://github.com/jupyterlab/jupyterlab-desktop/blob/master/user-guide.md
## 2. Managing Python packages: install, remove, update, and clean.
70
72
71
73
The following are the basic commands for installing, removing and and keep your Python libraries up to date.
72
74
@@ -94,20 +96,20 @@ conda clean --all
94
96
95
97
96
98
97
-
## More on conda/Python environments
99
+
## 3. Conda/Python environments: why and how
98
100
99
101
Environments enables you to have multiple versions of Python or scientific packages installed on your computer at the same time. This is useful, for example, to test a script on different versions of Python and any other Python library, or to keep separate different scientific libraries that may work with different Python versions, etc.
100
102
101
-
```
102
-
list all existing environments
103
-
>conda env list
103
+
```markdown
104
+
# list all existing environments
105
+
conda env list
104
106
```
105
107
106
-
### Create and remove an environment
108
+
### 3.1 Create and remove an environment
107
109
108
110
to create a new environment using conda the general procedure is as follows (in the anaconda prompt)
109
111
110
-
``>conda create --name <name of my env> <list of packages>``
112
+
``conda create --name <ENV NAME> <list of packages to install>``
111
113
112
114
> you can use ``-n`` instead of ``--name`` if preferred
More info here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
134
136
135
-
### Adding Python packaged from other channels or via pip in conda
137
+
### 3.2 Adding Python packages from other channels
136
138
137
139
At some point, you are likely to find yourself in the situation where you want to install a Python package that is not in the official (default) conda channel, and you need to install it using pip, the standard Python installation package, or the community-driven _conda-forge_ channel. In this case, it is strongly recommended to create a new Python environment and, in particular, never use pip to install packages into the Python environments you have for general use, as this may break compatibility between different versions of the environment.
An ``environment.ylm`` file is used to specify the dependencies for a Python project in conjunction with the ``conda`` package manager. It is a plain text file that looks like this:
172
+
An ``environment.ylm`` file is a YALM file used to specify the dependencies for a Python project in conjunction with the ``conda`` package manager. It is a plain text file that looks like this:
@@ -179,15 +181,17 @@ To create a conda environment using an ``environment.ylm`` file from the command
179
181
180
182
This will create a new conda environment called with the name defined within the ``environment.ylm`` file.
181
183
182
-
To create an ``environment.ylm`` file from a specific conda environmentdo as follows
184
+
On the other hand, if you want to create an ``environment.ylm`` file from your own conda environment, so that anyone can replicate it on their machine, do the following:
183
185
184
186
```markdown
187
+
# activate the specific environment
185
188
conda activate <environment name>
186
189
190
+
# create the YALM file
187
191
conda env export > environment.yml
188
192
```
189
193
190
-
This command will export the list of packages and their versions that are installed in the current active conda environment so that you can quickly share it with anyone.
194
+
This command exports the list of packages and their versions installed in the currently active conda environment, so that you can quickly share it with anyone.
191
195
192
196
> [!TIP]
193
-
> Sharing conda environments with other researchers facilitates reproducibility in research. So we encourage you to create and share environment.yml files in which you have conducted the data analysis every time you make a scientific publication.
197
+
> Sharing conda environments with other researchers facilitates reproducibility of research. We therefore encourage you to create and share the environment.yml files in which you have performed the data analysis each time you publish a scientific paper.
0 commit comments