trouble running python script with sudo [obsolete]
Posted: Sat Oct 12, 2013 5:09 am
so I have a python script running fine on my RPi when I trigger it with "python takeSpeech.py", however as soon as I add a sudo to it like:
sudo python takeSpeech.py
I get the following error:
Traceback (most recent call last):
File "takeSpeech.py", line 11, in <module>
import wolframalpha
ImportError: No module named wolframalpha
Here's the code up until that point:
here's what I know about the woflramalpha location/ls info:
pi@raspberrypi ~ $ sudo find / -name wolframalpha
/home/pi/.local/lib/python2.7/site-packages/wolframalpha-1.0.2-py2.7.egg/wolframalpha
pi@raspberrypi ~ $ ls -ld /home/pi/.local/lib/python2.7/site-packages/wolframalpha-1.0.2-py2.7.egg/wolframalpha
drwxr-xr-x 2 pi pi 4096 Jun 17 03:05 /home/pi/.local/lib/python2.7/site-packages/wolframalpha-1.0.2-py2.7.egg/wolframalpha
running the script DOES work with "sudo -E takeSpeech.py", however I'm adding this to an file in init.d which is automatically calling the python script using "sudo". Does anyone happen to know what I may need to change to get this working?
sudo python takeSpeech.py
I get the following error:
Traceback (most recent call last):
File "takeSpeech.py", line 11, in <module>
import wolframalpha
ImportError: No module named wolframalpha
Here's the code up until that point:
Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from collections import Counter
import time
import serial
from subprocess import Popen, PIPE, STDOUT
import os
import signal
import urllib
import urllib2, json
import wolframalphapi@raspberrypi ~ $ sudo find / -name wolframalpha
/home/pi/.local/lib/python2.7/site-packages/wolframalpha-1.0.2-py2.7.egg/wolframalpha
pi@raspberrypi ~ $ ls -ld /home/pi/.local/lib/python2.7/site-packages/wolframalpha-1.0.2-py2.7.egg/wolframalpha
drwxr-xr-x 2 pi pi 4096 Jun 17 03:05 /home/pi/.local/lib/python2.7/site-packages/wolframalpha-1.0.2-py2.7.egg/wolframalpha
running the script DOES work with "sudo -E takeSpeech.py", however I'm adding this to an file in init.d which is automatically calling the python script using "sudo". Does anyone happen to know what I may need to change to get this working?