|
76 | 76 | "Python 3.12.4\n",
|
77 | 77 | "```\n",
|
78 | 78 | "\n",
|
79 |
| - "Minor differences in the python version (beyond the first `.`) will not matter for the most part. However, unless you have a specific reason to use Python 2, the version should start with a 3. If it does not or if Python is not found on your system then you can install it via the [official website](https://www.python.org/downloads/).\n", |
| 79 | + "Minor differences in the python version (beyond the first `.`) will not matter for the most part. However, unless you have a specific reason to use Python 2, the version should start with a 3. If it does not or if Python is not found on your system then you can install it via the [official website](https://www.python.org/downloads/). Note that depending on your particular configuration, your Python might be accessed via another alias, such as 'python3' or 'py', resulting in the desired command being 'python3 --version'.\n", |
80 | 80 | "\n",
|
81 | 81 | "Typically Python is invoked by calling python followed by the path to a python script file, containing some code: \n",
|
82 | 82 | "\n",
|
|
148 | 148 | "pip install pandas\n",
|
149 | 149 | "```\n",
|
150 | 150 | "\n",
|
151 |
| - "Now when you check which packages are install using `pip list` you should see that pandas is installed and can be imported into code written with this environment active using `import pandas` (feel free to try this in the interactive shell). If you were to now run `deactivate` and `pip list` again you would see that the pandas packages is not listed. \n", |
| 151 | + "Now when you check which packages are installed using `pip list` you should see that pandas is installed and can be imported into code written with this environment active using `import pandas` (feel free to try this in the interactive shell). If you were to now run `deactivate` and `pip list` again you would see that the pandas packages is not listed. \n", |
152 | 152 | "\n",
|
153 | 153 | "This is the key goal of virtual environments: allowing you to easily swap between different configurations of packages and their respective versions without uninstalling and reinstalling everything. For example it might be the case that on one of your projects you need to use `pandas 2.2.2`, but that this is incompatible with some other package used in a different project, which only works with `pandas 1.8.0`. Using virtual environments allows each project to install the working version of pandas without replacing the version installed in the other project. \n",
|
154 | 154 | "\n",
|
|
205 | 205 | "Python 3.12.4\n",
|
206 | 206 | "```\n",
|
207 | 207 | "\n",
|
208 |
| - "Minor differences in the python version (beyond the first `.`) will not matter for the most part. However, unless you have a specific reason to use Python 2, the version should start with a 3. If it does not or if Python is not found on your system then you can install it via the [official website](https://www.python.org/downloads/).\n", |
| 208 | + "Minor differences in the python version (beyond the first `.`) will not matter for the most part. However, unless you have a specific reason to use Python 2, the version should start with a 3. If it does not or if Python is not found on your system then you can install it via the [official website](https://www.python.org/downloads/). Note that depending on your particular configuration, your Python might be accessed via another alias, such as 'python3' or 'py', resulting in the desired command being 'python3 --version'.\n", |
209 | 209 | "\n",
|
210 | 210 | "Typically Python is invoked by calling python followed by the path to a python script file, containing some code: \n",
|
211 | 211 | "\n",
|
|
241 | 241 | ".\\virtual_environment_1\\Scripts\\activate\n",
|
242 | 242 | "```\n",
|
243 | 243 | "\n",
|
244 |
| - "NOTE: Note: In PowerShell, you might need to prepend `.\\` to the command.\n", |
245 |
| - "Example: `.\\virtual_environment_1\\Scripts\\activate.`\n", |
246 |
| - "\n", |
247 | 244 | "After activation, your command line prompt will then change to indicate the environment name in parentheses, for example \n",
|
248 | 245 | "\n",
|
249 | 246 | "```shell\n",
|
|
288 | 285 | "```\n",
|
289 | 286 | "you should see pandas listed among your installed packages. This means you can use `import pandas` with Python scripts in this environment. If you leave the environment by typing `deactivate` and then check `pip list` again (outside the environment), you will not see pandas listed.\n",
|
290 | 287 | "\n",
|
291 |
| - "This is the key goal of virtual environments: allowing you to easily swap between different configurations of packages and their respective versions without uninstalling and reinstalling everything. For example it might be the case that on one of your projects you need to use `pandas 2.2.2`, but that this is incompatible with some other package used in a different project, which only works with `pandas 1.8.0`. Using virtual environments allows each project to install the working version of pandas without replacing the version installed in the other project. \n", |
| 288 | + "This is the key goal of virtual environments: allowing you to easily swap between different configurations of packages and their respective versions without uninstalling and reinstalling everything. For example, it might be the case that on one of your projects, you need to use `pandas 2.2.2`, but this is incompatible with some other package used in a different project, which only works with `pandas 1.8.0`. Using virtual environments allows each project to install the working version of pandas without replacing the version installed in the other project. \n", |
292 | 289 | "\n",
|
293 | 290 | "## Python Environment and Dependency Management Tools \n",
|
294 | 291 | "\n",
|
|
330 | 327 | "deactivate\n",
|
331 | 328 | "```\n",
|
332 | 329 | "\n",
|
333 |
| - "To install packages into the environment, a great method is to store all dependencies listed in a `requirements.txt` (rather than directly installing them with `pip install package_name`). This is because you can save and share this file alongside your repository, and it allows others to easily see and make a copy of the environment you used for your analysis - and for yourself to reproduce that environment, when you return to your code years later!\n", |
| 330 | + "A great method to install packages into the environment is to store all dependencies listed in a `requirements.txt` (rather than directly installing them with `pip install package_name`). This is because you can save and share this file alongside your repository, and it allows others to easily see and make a copy of the environment you used for your analysis - and for yourself to reproduce that environment, when you return to your code years later!\n", |
334 | 331 | "\n",
|
335 | 332 | "An example `requirements.txt` file:\n",
|
336 | 333 | "\n",
|
|
345 | 342 | "pip install -r requirements.txt\n",
|
346 | 343 | "```\n",
|
347 | 344 | "\n",
|
348 |
| - "To update your environment (such as if you to have add a new package to the requirements file):\n", |
| 345 | + "To update your environment (such as if you have to add a new package to the requirements file):\n", |
349 | 346 | "\n",
|
350 | 347 | "```sh\n",
|
351 | 348 | "pip install -r requirements.txt --upgrade\n",
|
|
378 | 375 | " - pytest-xdist==3.6.1\n",
|
379 | 376 | "```\n",
|
380 | 377 | "\n",
|
381 |
| - "To create environment from the file:\n", |
| 378 | + "To create an environment from the file:\n", |
382 | 379 | "\n",
|
383 | 380 | "```sh\n",
|
384 | 381 | "conda env create --name env_name --file environment.yml\n",
|
|
425 | 422 | "```\n",
|
426 | 423 | "\n",
|
427 | 424 | "### Poetry\n",
|
428 |
| - "Poetry bundles multiple tools for building and organising projects and managing dependencies. It makes use of venv to manage dependencies through a user-friendly interface, and also incorporates a build system to make your own projects easily installable (for example with pip). This is agreat way to standardise your workflow and make your work easy to reproduce! \n", |
| 425 | + "Poetry bundles multiple tools for building and organising projects and managing dependencies. It makes use of venv to manage dependencies through a user-friendly interface, and also incorporates a build system to make your own projects easily installable (for example with pip). This is a great way to standardise your workflow and make your work easy to reproduce! \n", |
429 | 426 | "\n",
|
430 | 427 | "[Poetry Tutorial](https://python-poetry.org/docs/)\n",
|
431 | 428 | "\n",
|
|
0 commit comments