Cannot run Python script using sudo

Solution 1:

By default sudo runs commands in different environment. You can ask sudo to preserve environment with -E switch.

sudo -E python myScriptName.py

It comes with it's own security risks. So be careful

Solution 2:

You need to check where signalr is installed. sudo runs the program in the environment available to root and if signalr is not installed globally it won't be picked up. Try 'sudo pip freeze' to see what is available in the root environment.