If you have errors in your locustfile your test will fail. These could be simple python parse errors, or actual issues with the definition of your test.
You can ensure your script parses by writing it to a file locally, e.g. example.py and parsing it:
python -m py_compile example.py
You can also install locust as shown and then test file locally, in our example it's example.py:
sudo pip3 install locust /usr/local/bin/locust -f example.py --host https://YOUR_HOST_HERE -u 10 -r 10 --run-time 1m