Some of the comments above are correct but they don't explain why.
The PATH environment variable is a list of filesystem paths that are searched for executable binaries, which usually looks like:
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
The PATH variable is appended by the SHELL you are using. In ubuntu, /bin/sh links to the default shell, which is dash for system boot scripts (i.e. cron). Dash is similar to bash but not identical. In terminals, Bash is used by default.
On Debian-based systems (i.e. Ubuntu), PATH is initialized by pam_env based on the content of /etc/environment:
$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
However, the shells like Dash/Bash also source /etc/profile and ~/.profile depending on how they are invoked (interactive vs login shell), where these scripts can append the PATH environment variable.
With all that said, speedtest-cli has to be in a folder on the PATH or you have to specify it using a full path. If you want option 1, you can try
*/1 * * * * . /home/pi/.profile ; speedtest-cli --csv >> /home/pi/speedtestLog.txt 2>&1
N.B. Thanks to steeldriver for pointing out that "source .profile" is a bashism and the posix standard is ". .profile".
speedtest-cli
? Use absolute or full path of speedtest-cli in crontab and see if it works. – Abhishek Nair Aug 18 '19 at 12:00./.local/lib/python2.7/site-packages
but it is not working as well – Marcelo Gazzola Aug 18 '19 at 12:12./
is not an absolute path. It should be/home/<username>...
– Pilot6 Aug 18 '19 at 12:14python /usr/local/lib/python2.7/dist-packages/speedtest.py
– Marcelo Gazzola Aug 18 '19 at 12:30