Skip to content

Commit ea1bb4e

Browse files
committed
Update installing_Python.md
1 parent 1321223 commit ea1bb4e

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

notebooks/installing_Python.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ conda env list
107107

108108
### 3.1 Create and remove an environment
109109

110-
to create a new environment using conda the general procedure is as follows (in the anaconda prompt)
110+
To create a new environment using Conda, the general procedure is as follows in the anaconda prompt:
111111

112112
``conda create --name <ENV NAME> <list of packages to install>``
113113

114+
> [!TIP]
114115
> you can use ``-n`` instead of ``--name`` if preferred
115116
116117
some examples below
@@ -122,7 +123,8 @@ conda create --name main python
122123
# create an environment with a specific version of Python
123124
conda create --name new_env python=3.8.1
124125

125-
# create an environment named "SCIENV" with the libraries numpy, scipy, matplolib and jupyterlab (conda will take care of including all the necessary dependencies)
126+
# create an environment named "SCIENV" with numpy, scipy, matplolib and jupyterlab
127+
# Note: conda will ensure that all other necessary dependencies be included.
126128
conda create --name SCIENV numpy scipy matplotlib jupyterlab
127129

128130
# create an environment named "image" with the library scikit-image and all the neccesary dependencies
@@ -136,24 +138,22 @@ More info here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/
136138

137139
### 3.2 Adding Python packages from other channels
138140

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.
141+
At some point, you may find that you want to install a Python package that is not available in the official conda channel. In this case, you will 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 that you create a new Python environment. In particular, you should never use pip to install packages into the Python environments that you use for general purposes, as this may cause compatibility issues between different versions of the environment.
140142

141143
#### Case 1: Python package installed using pip
142144

143-
Create a new Python environment and install the package and any necessary dependencies. Follow the developer's installation instructions.
145+
Create a new Python environment and install the package, along with any necessary dependencies. Follow the developer's installation instructions.
144146

145147
#### Case 2: the Python package is in the conda-forge channel
146148

147-
To install packages from the _conda-forge_ community channel, you must first activate it (see instructions below). Once this is done, create your new Python environment and install all the necessary libraries using conda.
148-
149-
To add the _conda-forge_ channel use:
149+
To install packages from the _conda-forge_ community channel, you must first activate it (see the instructions below). Once this is done, create your new Python environment and install all the necessary libraries using Conda. To add the _conda-forge_ channel use the following prompt:
150150

151151
```markdown
152152
conda config --append channels conda-forge
153153
```
154154

155155
> [!WARNING]
156-
> In most tutorials you can find on the internet you will find the following line to enable the conda-forge channel: ``conda config --add channels conda-forge``. **We advise you not to do this**. This will make conda-forge the priority channel in your Python installation. Your anaconda's default channel will have a lower priority, and some of your packages will start upgrading to conda-forge, affecting other environments as well. Using ``--append`` instead of ``--add`` will keep your default conda channel high in priority, and package versions will be searched on your default before going to conda-forge. If you have already made a mess of it, you can use the following lines:
156+
> Most online tutorials will include the following line to enable the _conda-forge_ channel: ``conda config --add channels conda-forge``. **We advise you not to do this**. This prioritises the conda-forge channel over Anaconda's default channel in your Python installation. As a result, some of your packages will start upgrading to _conda-forge_ versions, which will affect other Python environments as well. Using ``--append`` instead of ``--add`` keeps the default conda channel at the top of the priority channels, meaning that package versions will be searched on the default channel before going to _conda-forge_. If you have made a mess or are unsure about the channel priorities in your installation, you can use the following prompts:
157157
>
158158
> ```markdown
159159
> # show channels
@@ -162,26 +162,25 @@ conda config --append channels conda-forge
162162
> # describe channel priority
163163
> conda config --describe channel_priority
164164
>
165-
> # remove conda-forge
165+
> # Remove Conda Forge if it is the priority channel
166166
> conda config --remove channels conda-forge
167+
>
168+
> # reinstall it (if needed)
169+
> conda config --append channels conda-forge
167170
> ```
168171
169172
170173
### 3.3 Using environment.ylm (YALM) files
171174
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:
175+
An ``environment.ylm`` file is a YALM file that specifies the dependencies for a Python project when used with the conda package manager. A YALM file is simply a plain text file that looks like this:
173176
174177
![image-20221215134600921](https://github.com/marcoalopez/Python_course/blob/main/img/image-20221215134600921.png?raw=true)
175178
176-
These files are a useful way to share Python environments and ensure, for example, that anyone else using your code does so in the same environment as you regardless of the operating system or machine where the code runs.
177-
178-
To create a conda environment using an ``environment.ylm`` file from the command lines use (if you are in the folder containing the ``environment.ylm`` otherwise you will have to specify the path)
179+
These files are a useful way to share Python environments and ensure that anyone else using your code does so in the same environment as you regardless of the operating system or machine where the code runs. To create a Conda environment using an ``environment.ylm`` file from the command line use (if you are in the folder containing the ``environment.ylm`` otherwise you will have to specify the path)
179180
180181
``conda env create -f environment.yml``
181182
182-
This will create a new conda environment called with the name defined within the ``environment.ylm`` file.
183-
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+
This will create a new Conda environment called with the name defined within the ``environment.ylm`` file. If you want to create an ``environment.ylm`` file from a Conda environment use the following prompts:
185184
186185
```markdown
187186
# activate the specific environment
@@ -191,7 +190,7 @@ conda activate <environment name>
191190
conda env export > environment.yml
192191
```
193192
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.
193+
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.
195194
196195
> [!TIP]
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.
196+
> Sharing Conda environments with other researchers makes research more reproducible. We encourage researchers to create and share ``environment.yml`` files for each piece of data analysis they perform when publishing a scientific paper.

0 commit comments

Comments
 (0)