2016-11-30 62 views
1

我在這裏嘗試了本教程: http://www.instructables.com/id/Orange-Pi-One-Python-GPIO-basic/?ALLSTEPS蟒蛇 - 編譯錯誤 - 無法導入名稱「GPIO」

每當我執行我的.py文件,我得到錯誤「無法導入名稱‘GPIO’」

這這裏是我別的都安裝後使用的代碼,在嘖嘖稱:

#import the library 
from pyA20.gpio import gpio 
from pyA20.gpio import port 
from time import sleep 

#initialize the gpio module 
gpio.init() 

#setup the port (same as raspberry pi's gpio.setup() function) 
gpio.setcfg(port.PA7, gpio.OUTPUT) 

#now we do something (light up the LED) 
gpio.output(port.PA7, gpio.HIGH) 

#turn off the LED after 2 seconds 
sleep(2) 
gpio.output(port.PA7, gpio.LOW) 

我很新的這一切,所以請多多包涵。 非常感謝。

+1

完整回溯是*始終*漂亮 –

+1

的可能的複製[ImportError:無法導入名稱X](http://stackoverflow.com/questions/9252543/importerror-cannot-import-name-x) – user2728397

+0

您是否從教程庫中運行'setup.py'? –

回答

1

上了車橙色PI零同樣的問題......我從https://pypi.python.org/pypi/pyA10Lime得到了Python庫,然後它的工作:

[email protected]:~# wget https://pypi.python.org/packages/e6/52/a6b558fd5c8eb11e5de710271d59881769425e61d3adf6d235836ca877cc/pyA10Lime-0.2.1.tar.gz 
[email protected]:~# tar -zxf pyA10Lime-0.2.1.tar.gz 
[email protected]:~# cd pyA10Lime-0.2.1/ 
[email protected]:~/pyA10Lime-0.2.1# 
[email protected]:~/pyA10Lime-0.2.1# vi setup.py 
# 
# @line 60, add : 
#    elif "sun8i" in processor: 
#     print ("Detected processor: " + print_color(processor) + " (Probably Allwinner H2+/H3)") 
# 
[email protected]:~/pyA10Lime-0.2.1# python setup.py install 
[email protected]:~/pyA10Lime-0.2.1# python 
Python 2.7.9 (default, Aug 13 2016, 17:56:53) 
[GCC 4.9.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from pyA20.gpio import gpio 
>>> from pyA20.gpio import port 
>>> gpio.init() 
>>> gpio.setcfg(port.PG7, gpio.OUTPUT) 
>>> gpio.output(port.PG7, gpio.HIGH) 
>>> 
>>> gpio.output(port.PG7, gpio.LOW) 
>>> exit() 

有用的鏈接https://forum.armbian.com/index.php?/topic/3655-guide-orange-pi-zero-gpios/

+0

我愛你的男人!確認工作。 – BiTinerary

相關問題