我有一个关于在 Python 中通过 execfile() 执行脚本的问题
我的主要脚本位于home/pi/var/www/html/main.py
. 我的第二个脚本是home/pi/start.py
并且包括几个模块。
当我execfile("/home/pi/start.py")
收到此错误时:
<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'
如果有人知道答案,请随时分享。