My vacation home loses the internet connection from time to time which means I cannot access that locations' home network remotely. I am using a wireless Bell service as my ISP. When I am at the vacation home, I have a program within my home automation system to reboot the Bell PoE device and the Modem. This generally always resets the network.
I am trying to use the Github project Python script speedtest-cli to measure the download speed at my vacation home. I am trying to write my own Python script, on a Raspberry Pi (Buster), to periodically measure the download speed of the internet. My plan is to then send a variable, with the speed, to my home automation system that will trigger a reset of the internet if the speed is too low.
I downloaded the latest script from Github using the code
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
Then I made the file executable with
chmod +x speedtest-cli
When I run the command speedtest-cli, at the Raspeberry Pi's command line, the script works as expected and I see the download speed.
However, when I try to incorporate the code into a python script I get the error 'No module named 'speedtest'
The simple code that yields this message is
import speedtest
I am running the simple script above from the /home/pi/ directory and the executable 'speedtest-cli' is also in that directory
(I know that there are numerous comments that this 'speedtest' project isn't providing accurate results, however from my testing it has been consistently yielding results that are sufficient for my purposes)
Any thought on why this isn't working?