I have a question about executing a script via execfile() in Python
My main script is located at home/pi/var/www/html/main.py. My second script is home/pi/start.py and includes several modules.
When I execfile("/home/pi/start.py") I get this error:
<type 'exceptions.ImportError'> Python 2.7.9: /usr/bin/python
Tue May 10 18:27:41 2016
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/var/www/html/main.py in ()
207
208 sys.stdout.flush()
209
210 if __name__=="__main__":
=> 211 main()
main = <function main>
/var/www/html/web.py in main()
165
166 if start is not None:
=> 167 execfile("/home/pi/test.py")
168
169 # 1 staat voor laatste uur
builtin execfile = <built-in function execfile>
/home/pi/start.py in ()
2 import time
3 import RPi.GPIO as GPIO
4 import os
5 import sqlite3
6 import Adafruit_DHT
pid undefined
<type 'exceptions.ImportError'>: No module named pid
args = ('No module named pid',)
message = 'No module named pid'
If someone know the answer feel free to share.
No module named ...is not particularly helpful in understanding where you are running into problems, also note thatexecfileis not the same thing as running it as a seperate process So any relative imports would be with respect to the original file.