From 56e657e01528c228e425bfdec4b77730969db973 Mon Sep 17 00:00:00 2001 From: Jim Bennett Date: Fri, 30 Jul 2021 10:12:39 -0700 Subject: [PATCH] Adding more on virtual environments. (#274) * Update README.md * Spelling fixes * Update hardware.md * Adding IoT for beginners episode * Adding intro video * Fixing formatting of read more and self study sections. * Adding instructions for installing the ReSpeaker * Adding auth to language understanding * Adding Wio terminal timer setting * Update config.h * Fixing links and images * Increasing version numbers for SD card fix * Adding SD card requirement * speech and translations * Adding more on translations * All Wio Terminal now working except playing audio * Adding more details on virtual environments. --- 1-getting-started/lessons/1-introduction-to-iot/pi.md | 8 ++++++-- .../lessons/1-introduction-to-iot/virtual-device.md | 10 ++++++---- 1-getting-started/lessons/4-connect-internet/README.md | 10 +++++----- .../single-board-computer-commands.md | 2 +- .../4-connect-internet/single-board-computer-mqtt.md | 2 +- .../single-board-computer-telemetry.md | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/1-getting-started/lessons/1-introduction-to-iot/pi.md b/1-getting-started/lessons/1-introduction-to-iot/pi.md index d975860..3e8fffd 100644 --- a/1-getting-started/lessons/1-introduction-to-iot/pi.md +++ b/1-getting-started/lessons/1-introduction-to-iot/pi.md @@ -49,7 +49,9 @@ To program the Pi using the Grove sensors and actuators, you will need to instal curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s - ``` - One of the powerful features of Python is the ability to install [pip packages](https://pypi.org) - these are packages of code written by other people and published to the Internet. You can install a pip package onto your computer with one command, then use that package in your code. This Grove install script will install the pip packages you will use to work with the Grove hardware from Python. + One of the powerful features of Python is the ability to install [Pip packages](https://pypi.org) - these are packages of code written by other people and published to the Internet. You can install a Pip package onto your computer with one command, then use that package in your code. This Grove install script will install the Pip packages you will use to work with the Grove hardware from Python. + + > 💁 By default when you install a package it is available everywhere on your computer, and this can lead to problems with package versions - such as one application depending on one version of a package that breaks when you install a new version for a different application. To work around this problem, you can use a [Python virtual environment](https://docs.python.org/3/library/venv.html), essentially a copy of Python in a dedicated folder, and when you install Pip packages they get installed just to that folder. You won't be using virtual environments when using your Pi. The Grove install script installs the Grove Python packages globally, so to use a virtual environment you would need to set up a virtual environment then manually re-install the Grove packages inside that environment. It's easier to just use global packages, especially as a lot of Pi developers will re-flash a clean SD card for each project. 1. Reboot the Pi either using the menu or running the following command in the Terminal: @@ -163,7 +165,9 @@ Configure the installed Pi software and install the Grove libraries. curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s - ``` - One of the powerful features of Python is the ability to install [pip packages](https://pypi.org) - these are packages of code written by other people and published to the Internet. You can install a pip package onto your computer with one command, then use that package in your code. This Grove install script will install the pip packages you will use to work with the Grove hardware from Python. + One of the powerful features of Python is the ability to install [Pip packages](https://pypi.org) - these are packages of code written by other people and published to the Internet. You can install a Pip package onto your computer with one command, then use that package in your code. This Grove install script will install the Pip packages you will use to work with the Grove hardware from Python. + + > 💁 By default when you install a package it is available everywhere on your computer, and this can lead to problems with package versions - such as one application depending on one version of a package that breaks when you install a new version for a different application. To work around this problem, you can use a [Python virtual environment](https://docs.python.org/3/library/venv.html), essentially a copy of Python in a dedicated folder, and when you install Pip packages they get installed just to that folder. You won't be using virtual environments when using your Pi. The Grove install script installs the Grove Python packages globally, so to use a virtual environment you would need to set up a virtual environment then manually re-install the Grove packages inside that environment. It's easier to just use global packages, especially as a lot of Pi developers will re-flash a clean SD card for each project. 1. Reboot the Pi by running the following command: diff --git a/1-getting-started/lessons/1-introduction-to-iot/virtual-device.md b/1-getting-started/lessons/1-introduction-to-iot/virtual-device.md index ec10179..132186b 100644 --- a/1-getting-started/lessons/1-introduction-to-iot/virtual-device.md +++ b/1-getting-started/lessons/1-introduction-to-iot/virtual-device.md @@ -30,13 +30,15 @@ This app will be in a folder called `nightlight`, and it will be re-used with di ### Configure a Python virtual environment -One of the powerful features of Python is the ability to install [pip packages](https://pypi.org) - these are packages of code written by other people and published to the Internet. You can install a pip package onto your computer with one command, then use that package in your code. You'll be using pip to install a package to talk to CounterFit. +One of the powerful features of Python is the ability to install [Pip packages](https://pypi.org) - these are packages of code written by other people and published to the Internet. You can install a Pip package onto your computer with one command, then use that package in your code. You'll be using Pip to install a package to talk to CounterFit. -By default when you install a package it is available everywhere on your computer, and this can lead to problems with package versions - such as one application depending on one version of a package that breaks when you install a new version for a different application. To work around this problem, you can use a [Python virtual environment](https://docs.python.org/3/library/venv.html), essentially a copy of Python in a dedicated folder, and when you install pip packages they get installed just to that folder. +By default when you install a package it is available everywhere on your computer, and this can lead to problems with package versions - such as one application depending on one version of a package that breaks when you install a new version for a different application. To work around this problem, you can use a [Python virtual environment](https://docs.python.org/3/library/venv.html), essentially a copy of Python in a dedicated folder, and when you install Pip packages they get installed just to that folder. + +> 💁 If you are using a Raspberry Pi then you didn't set up a virtual environment on that device to manage Pip packages, instead you are using global packages, as the Grove packages are installed globally by the installer script. #### Task - configure a Python virtual environment -Configure a Python virtual environment and install the pip packages for CounterFit. +Configure a Python virtual environment and install the Pip packages for CounterFit. 1. From your terminal or command line, run the following at a location of your choice to create and navigate to a new directory: @@ -91,7 +93,7 @@ Configure a Python virtual environment and install the pip packages for CounterF > 💁 Your Python version may be different - as long as it's version 3.6 or higher you are good. If not, delete this folder, install a newer version of Python and try again. -1. Run the following commands to install the pip packages for CounterFit. These packages include the main CounterFit app as well as shims for Grove hardware. These shims allow you to write code as if you were programming using physical sensors and actuators from the Grove ecosystem but connected to virtual IoT devices. +1. Run the following commands to install the Pip packages for CounterFit. These packages include the main CounterFit app as well as shims for Grove hardware. These shims allow you to write code as if you were programming using physical sensors and actuators from the Grove ecosystem but connected to virtual IoT devices. ```sh pip install CounterFit diff --git a/1-getting-started/lessons/4-connect-internet/README.md b/1-getting-started/lessons/4-connect-internet/README.md index 31567fc..18233d7 100644 --- a/1-getting-started/lessons/4-connect-internet/README.md +++ b/1-getting-started/lessons/4-connect-internet/README.md @@ -124,7 +124,7 @@ The cloud service can then use this telemetry data to make decisions around what The next part in adding Internet control to your nightlight is sending the light level telemetry to the MQTT broker on a telemetry topic. -#### Task +#### Task - send telemetry from your IoT device Send light level telemetry to the MQTT broker. @@ -145,9 +145,9 @@ There's no point in sending telemetry if there's nothing on the other end to lis #### Install Python and VS Code -If you don't have Python and VS Code installed locally, you will need to install them both to code the server. If you are using a virtual device, or are working on your Raspberry Pi you can skip this step. +If you don't have Python and VS Code installed locally, you will need to install them both to code the server. If you are using a virtual IoT device, or are working on your Raspberry Pi you can skip this step as you should already have this installed and configured. -##### Task +##### Task - install Python and VS Code Install Python and VS Code. @@ -165,7 +165,7 @@ One of the powerful features of Python is the ability to install [pip packages]( By default when you install a package it is available everywhere on your computer, and this can lead to problems with package versions - such as one application depending on one version of a package that breaks when you install a new version for a different application. To work around this problem, you can use a [Python virtual environment](https://docs.python.org/3/library/venv.html), essentially a copy of Python in a dedicated folder, and when you install pip packages they get installed just to that folder. -##### Task +##### Task - configure a Python virtual environment Configure a Python virtual environment and install the MQTT pip packages. @@ -234,7 +234,7 @@ Configure a Python virtual environment and install the MQTT pip packages. The server code can now be written in Python. -##### Task +##### Task - write the server code Write the server code. diff --git a/1-getting-started/lessons/4-connect-internet/single-board-computer-commands.md b/1-getting-started/lessons/4-connect-internet/single-board-computer-commands.md index 84464cb..65ff56a 100644 --- a/1-getting-started/lessons/4-connect-internet/single-board-computer-commands.md +++ b/1-getting-started/lessons/4-connect-internet/single-board-computer-commands.md @@ -12,7 +12,7 @@ Subscribe to commands. 1. Open the nightlight project in VS Code. -1. If you are using a virtual IoT device, ensure the terminal is running the virtual environment +1. If you are using a virtual IoT device, ensure the terminal is running the virtual environment. If you are using a Raspberry Pi you won't be using a virtual environment. 1. Add the following code after the definitions of the `client_telemetry_topic`: diff --git a/1-getting-started/lessons/4-connect-internet/single-board-computer-mqtt.md b/1-getting-started/lessons/4-connect-internet/single-board-computer-mqtt.md index a1f11d1..3d2e1ff 100644 --- a/1-getting-started/lessons/4-connect-internet/single-board-computer-mqtt.md +++ b/1-getting-started/lessons/4-connect-internet/single-board-computer-mqtt.md @@ -14,7 +14,7 @@ Install the pip package 1. Open the nightlight project in VS Code. -1. If you are using a virtual IoT device, ensure the terminal is running the virtual environment. +1. If you are using a virtual IoT device, ensure the terminal is running the virtual environment. If you are using a Raspberry Pi you won't be using a virtual environment. 1. Run the following command to install the MQTT pip package: diff --git a/1-getting-started/lessons/4-connect-internet/single-board-computer-telemetry.md b/1-getting-started/lessons/4-connect-internet/single-board-computer-telemetry.md index 08bf601..6cae5fa 100644 --- a/1-getting-started/lessons/4-connect-internet/single-board-computer-telemetry.md +++ b/1-getting-started/lessons/4-connect-internet/single-board-computer-telemetry.md @@ -12,7 +12,7 @@ Publish telemetry to the MQTT broker. 1. Open the nightlight project in VS Code. -1. If you are using a virtual IoT device, ensure the terminal is running the virtual environment +1. If you are using a virtual IoT device, ensure the terminal is running the virtual environment. If you are using a Raspberry Pi you won't be using a virtual environment. 1. Add the following import to the top of the `app.py` file: