From 642f1c5eb2d58ff21c3afa701e3a26775e552d11 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Fri, 14 Mar 2025 16:36:36 +0100 Subject: [PATCH 1/3] update setup instructions --- learners/setup.md | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/learners/setup.md b/learners/setup.md index 0d40c017..83249259 100644 --- a/learners/setup.md +++ b/learners/setup.md @@ -2,46 +2,19 @@ title: Setup --- -## Installing Python Using Anaconda -Python is a popular language for research computing, and great for general-purpose programming as well. Installing all of its research packages individually can be a bit difficult, so we recommend Anaconda, an all-in-one installer. +## Installing Python Using Miniforge -Regardless of how you choose to install it, please make sure you install Python 3.6 or above. The latest 3.x version recommended on [Python.org][python] is fine. +[Python](https://python.org) is a popular language for scientific computing, and great for general-purpose programming as well. +For this workshop we use Python version 3.x. +Installing all of its scientific packages individually can be a bit difficult, so we provide an environment file to help you take care of them all together. +We will use the _Miniforge_ distribution of Python. -We will teach Python using JupyterLab, a programming environment that runs in a web browser (JupyterLab will be installed by Anaconda). For this to work you will need a reasonably up-to-date browser. The current versions of the Chrome, Safari and Firefox browsers are all supported (some older browsers, including Internet Explorer version 9 and below, are not). - -::::::::::::::::: tab - -### Windows - -[Watch a video tutorial for Windows][video-windows]. - -1. Open [anaconda.com/download][anaconda-dl] with your web browser. -2. Download the Anaconda for Windows installer with Python 3. (If you are not sure which version to choose, you probably want the 64-bit Graphical Installer *Anaconda3-...-Windows-x86_64.exe*) -3. Install Python 3 by running the Anaconda Installer, using all of the defaults for installation except make sure to check *Add Anaconda to my PATH environment variable*. - -### Mac - -[Watch a video tutorial for Mac][video-mac]. - -1. Open [anaconda.com/download][anaconda-dl] with your web browser. -2. Download the Anaconda Installer with Python 3 for macOS (you can either use the Graphical or the Command Line Installer). -3. Install Python 3 by running the Anaconda Installer using all of the defaults for installation. - -### Linux - -Note that the following installation steps require you to work from the shell. If you aren't comfortable doing the installation yourself stop here and request help from the workshop organizers. - -1. Open [anaconda.com/download][anaconda-dl] with your web browser. -2. Download the Anaconda Installer with Python 3 for Linux. -3. Open a terminal window and navigate to the directory where the executable is downloaded (e.g., `cd ~/Downloads`). -4. Type `bash Anaconda3` and press Tab to auto-complete the full file name. The name of file you just downloaded should appear. -5. Press Enter (or Return depending on your keyboard). You will follow the text-only prompts. To move through the text, press Spacebar. Type `yes` and press Enter to approve the license. Press Enter (or Return) to approve the default location for the files. Type `yes` and press Enter (or Return) to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python). -6. Close the terminal window. - -::::::::::::::::::::::::: +Please refer to the [Python section of the workshop website for installation instructions](https://carpentries.github.io/workshop-template/install_instructions/#python). ## JupyterLab -We will teach Python using JupyterLab, a part of a family of [Jupyter][jupyter] tools that includes Jupyter Notebook and JupyterLab, both of which provide interactive web environments where you can write and run Python code. If you installed Anaconda, JupyterLab is installed on your system. If you did not install Anaconda, you can [install JupyterLab][jupyter-install] on its own using conda, pip, or other popular package managers. +We will teach Python using JupyterLab, a part of a family of [Jupyter][jupyter] tools that includes Jupyter Notebook and JupyterLab, both of which provide interactive web environments where you can write and run Python code. +If you followed the instructions linked above, JupyterLab is installed on your system. +Alternatively, you can [install JupyterLab][jupyter-install] on its own using conda, pip, or other popular package managers. ## Download the data @@ -53,7 +26,6 @@ This lesson uses circulation data in multiple CSV files from the Chicago Public [python]: https://python.org/downloads [video-windows]: https://www.youtube.com/watch?v=xxQ0mzZ8UvA -[anaconda-dl]: https://www.anaconda.com/download/ [video-mac]: https://www.youtube.com/watch?v=TcSAln46u9U [jupyter]: https://docs.jupyter.org/en/latest/ [jupyter-install]: https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html From 2d7235f758dc762e4b1eaeb03111e6641de34e28 Mon Sep 17 00:00:00 2001 From: Cody Hennesy Date: Sun, 16 Mar 2025 13:48:50 -0700 Subject: [PATCH 2/3] updates for conda forge --- episodes/data-visualisation.md | 8 +------- episodes/getting-started.md | 22 ++++++++++------------ index.md | 2 +- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/episodes/data-visualisation.md b/episodes/data-visualisation.md index 8bebe48f..0b834a02 100644 --- a/episodes/data-visualisation.md +++ b/episodes/data-visualisation.md @@ -141,15 +141,9 @@ albany['circulation'].plot(kind='hist', bins=20, ## Use Plotly for interactive plots Let’s switch back to the full DataFrame in `df_long` and use another -plotting package in Python called Plotly. First let’s install and then use the package. +plotting package in Python called Plotly. ```python -# uncomment below to install plotly if the import fails. -# !pip install plotly - -# if you didn't install Jupyter via Anaconda, you may also need to install ipywidgets. -# !pip install ipywidgets - import plotly.express as px ``` diff --git a/episodes/getting-started.md b/episodes/getting-started.md index b4e6d2d3..3b2ffe74 100644 --- a/episodes/getting-started.md +++ b/episodes/getting-started.md @@ -51,7 +51,7 @@ Here a few areas where you might apply Python in your work. ## Use JupyterLab to edit and run Python code. -If you haven't already done so, see [the setup instructions](../learners/setup.md) for details on how to install JupyterLab and Python via Anaconda. The setup instructions also walk you through the steps you should follow to create an `lc-python` folder on your Desktop, and to download and unzip the dataset we'll be working with inside of that directory. +If you haven't already done so, see [the setup instructions](../learners/setup.md) for details on how to install JupyterLab and Python using Miniforge. The setup instructions also walk you through the steps you should follow to create an `lc-python` folder on your Desktop, and to download and unzip the dataset we'll be working with inside of that directory. ### Getting started with JupyterLab To run Python, we are going to use Jupyter Notebooks via [JupyterLab][jupyterlab]. Jupyter notebooks are common tools for data science and visualization, and serve as a convenient environment for running Python code interactively where we can view and share the results of our Python code. @@ -76,10 +76,15 @@ Once you have created the `lc-python` directory on your Desktop, you can start J #### Mac users - Command Line 1. Press the cmd + spacebar keys and search for `Terminal`. Click the result or press return. (You can also find `Terminal` in your `Applications` folder, under `Utilities`.) -2. After you have launched Terminal, change directories to the `lc-python` folder you created earlier and type `jupyter lab`. Note that the `$` sign is used to indicate a command to be typed on the command prompt, but we never type the `$` sign itself, just what follows after it. +2. After you have launched Terminal, change directories to the `lc-python` folder you created earlier. +3. Next run `conda activate carpentries` to launch a Python environment which includes Jupyter Notebooks and other tools we will need to proceed through the lesson. +4. Finally, type `jupyter lab` which should open a browser window where you can run Jupyter Notebooks. + +Note that the `$` sign is used to indicate a command to be typed on the command prompt, but we never type the `$` sign itself, just what follows after it. ```bash $ cd ../Desktop/lc-python +$ conda activate carpentries $ jupyter lab ``` @@ -89,22 +94,15 @@ To start the JupyterLab server you will need to access the Anaconda Prompt. 1. Press the Windows Logo Key and search for `Anaconda Prompt`, click the result or press enter. -2. Once you have launched the Anaconda Prompt, type the command `jupyter lab`. Note that the `$` sign is used to indicate a command to be typed on the command prompt, but we never type the `$` sign itself, just what follows after it. +2. Once you have launched the Anaconda Prompt, type the command `jupyter lab`. + +Note that the `$` sign is used to indicate a command to be typed on the command prompt, but we never type the `$` sign itself, just what follows after it. ```bash $ cd ..\Desktop\lc-python $ jupyter lab ``` -#### Start JupyterLab from Anaconda Navigator -If you are unfamiliar with the command line, you can launch JupyterLab by opening the Anaconda Navigator app and choosing the `Launch` button underneath the JuypterLab icon. - -First [start Anaconda Navigator (click for detailed instructions on macOS, Windows, and Linux)](https://docs.anaconda.com/free/navigator/getting-started/#navigator-starting-navigator). You can search for Anaconda Navigator via Spotlight on macOS (Command + spacebar), or by using the Windows search function (Windows Logo Key). - -After you have launched Anaconda Navigator, click the `Launch` button under JupyterLab. You may need to scroll down to find it. Here is a screenshot of an Anaconda Navigator page similar to the one that should open on either macOS or Windows. - -![Launch JupyterLab from Anaconda Navigator](../episodes/fig/0_anaconda_navigator_landing_page.png){alt='screenshot of the launch button for JuypterLab in Anaconda Navigator'} - ## The JupyterLab Interface Launching JupyterLab opens a new tab or window in your preferred web browser. While JupyterLab enables you to run code from your browser, it does not require you to be online. If you take a look at the URL in your browser address bar, you should see that the environment is located at your localhost, meaning it is running from your computer: `http://localhost:8888/lab`. diff --git a/index.md b/index.md index 21a10974..18340b93 100644 --- a/index.md +++ b/index.md @@ -19,7 +19,7 @@ This lesson is an introduction to programming in Python for library and informat 2. Learners must install Python and JupyterLab, and download the dataset that will be used in the lesson, before the workshop begins. - Please see setup instructions below for details. + Please see setup instructions below for details. :::::::::::::::::::::::::::::::::::::::::::::::::: From 0df20d80aebae3778913aa874c76478d3e29a191 Mon Sep 17 00:00:00 2001 From: Cody Hennesy Date: Tue, 18 Mar 2025 08:53:36 -0700 Subject: [PATCH 3/3] fix windows and remove anaconda --- episodes/getting-started.md | 13 +++++++------ episodes/libraries.md | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/episodes/getting-started.md b/episodes/getting-started.md index 3b2ffe74..bfff0174 100644 --- a/episodes/getting-started.md +++ b/episodes/getting-started.md @@ -71,7 +71,7 @@ Jupyter notebooks let us execute and view the results of our Python code immedia - Each notebook contains one or more cells that contain code, text, or images. ### Start JupyterLab -Once you have created the `lc-python` directory on your Desktop, you can start JupyterLab by opening a shell command line interface or by using Anaconda Navigator. +Once you have created the `lc-python` directory on your Desktop, you can start JupyterLab by opening a shell command line interface. #### Mac users - Command Line @@ -92,14 +92,16 @@ $ jupyter lab To start the JupyterLab server you will need to access the Anaconda Prompt. -1. Press the Windows Logo Key and search for `Anaconda Prompt`, click the result or press enter. - -2. Once you have launched the Anaconda Prompt, type the command `jupyter lab`. +1. Press the Windows Logo Key and search for `Miniforge Prompt`, click the result or press enter. +2. Once you have launched the Miniforge Prompt, change directories to the `lc-python` folder you created earlier. (The example below assumes a starting path of `C:\Users\username`) +3. Next run `conda activate carpentries` to launch a Python environment which includes Jupyter Notebooks and other tools we will need to proceed through the lesson. +4. Finally, type `jupyter lab` which should open a browser window where you can run Jupyter Notebooks. Note that the `$` sign is used to indicate a command to be typed on the command prompt, but we never type the `$` sign itself, just what follows after it. ```bash -$ cd ..\Desktop\lc-python +$ cd \Desktop\lc-python +$ conda activate carpentries $ jupyter lab ``` @@ -189,7 +191,6 @@ You can also use "hotkeys"" to change Jupyter cells from Code to Markdown and ba - Press the y key to convert the cell back to Code. :::::::::::::::::::::::::::::::::::::::::::::::::: -[anaconda]: https://docs.anaconda.com/anaconda/install/ [spyder]: https://www.spyder-ide.org/ [jupyterlab]: https://jupyterlab.readthedocs.io/en/stable/ diff --git a/episodes/libraries.md b/episodes/libraries.md index 2279c8b9..42966db4 100644 --- a/episodes/libraries.md +++ b/episodes/libraries.md @@ -120,7 +120,7 @@ The ASCII letters are abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ## Module not found error -Before you can import a Python library, you sometimes will need to download and install it on your machine. Anaconda comes with many of the most popular Python libraries for scientific computing applications built-in, so if you installed Anaconda for this workshop, you'll be able to import many common libraries directly. Some less common tools, like the PyMarc library, however, would need to be installed first. +Before you can import a Python library, you sometimes will need to download and install it on your machine. The Carpentries conda environment that we're using for the workshop installs a number of common Python libraries for academic computing. Since those are available when you activate the environment you'll be able to import many common libraries directly. Some less common tools, like the PyMarc library, however, would need to be installed first. ```python import pymarc @@ -130,7 +130,7 @@ import pymarc ModuleNotFoundError: No module named 'pymarc' ``` -You can find out how to install the library by looking at the documentation. [PyMarc](https://pypi.org/project/pymarc/), for example, recommends using a command line tool, `pip`, to install it. You can install with pip in a Jupyter notebook by starting the command with a percentage symbol, which allows you to run shell commands from Jupyter: +You can find out how to install the library by looking at the documentation. [PyMarc](https://pypi.org/project/pymarc/), for example, recommends using a command line tool, `pip`, for installation, though you can also [install PyMarc using conda](https://anaconda.org/asmeurer/pymarc). To install with pip in a Jupyter notebook you can begin the command with a percentage symbol, which allows you to run shell commands from Jupyter: ```python %pip install pymarc