我遵循了教程(https://sites.google.com/site/programmersnotebook/remote-development-of-python-scripts-on-raspberry-pi-with-eclipse),我可以从eclipse客户端(Windows 7)成功连接到服务器(在本例中为raspberry pi)。当我运行像
这样的简单python时print 'hello'
一切正常。但是当我运行以下时
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def printFunction(channel):
print("Button 1 pressed!")
print("Note how the bouncetime affects the button press")
GPIO.add_event_detect(23, GPIO.RISING, callback=printFunction, bouncetime=300)
while True:
GPIO.wait_for_edge(24, GPIO.FALLING)
print("Button 2 Pressed")
GPIO.wait_for_edge(24, GPIO.RISING)
print("Button 2 Released")
GPIO.cleanup()
我得到以下
pydev debugger: starting (pid: 7744)
Traceback (most recent call last):
File "C:\eclipse\plugins\org.python.pydev_3.7.0.201408261926\pysrc\pydevd.py", line 2086, in <module>
debugger.run(setup['file'], None, None)
File "C:\eclipse\plugins\org.python.pydev_3.7.0.201408261926\pysrc\pydevd.py", line 1543, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Users\francis.reed\workspace\RemoteSystemsTempFiles\10.137.10.110\home\francis\raspiproj\test.py", line 1, in <module>
import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO
注意:RPi.GPIO仅安装在服务器(raspberry pi)而不是eclipse客户端(Windows 7)。
有没有办法运行脚本,让所有import语句查找服务器上的模块(rapsberry pi)而不是eclipse客户端(windows 7)?
感谢任何帮助!
答案 0 :(得分:0)
我有这个工作......我想我有一些问题。首先,我试图错误地运行远程调试会话。这个链接更具体一点: http://pydev.org/manual_adv_remote_debugger.html
此外,我的主机IP地址已更改,因此在pydevd.settrace()命令中不正确。
启动远程调试器,在代码中添加断点,然后从Eclipse中的Remote Shell窗口启动运行脚本。