보물창고/Programming2015.11.11 23:00





해결 GPIO.setmode(GPIO.BOARD) AttributeError: 'module' object has no attribute 'setmode'



raspberry pi에서 RFID-RC522를 이용한 카드인식 시스템을 만들고 있었는데요

setmode에러가나서 한참을 고생하다 구글링을 통해 해결했습니다






구글 검색어
GPIO.setmode(GPIO.BOARD) AttributeError: 'module' object has no attribute 'setmode'

참고한 내용





출력된 에러

 

$sudo python Dump.py
Traceback (most recent call last):
File "Dump.py", line 21, in <module>
MIFAREReader = MFRC522.MFRC522()
File "/home/imcloud/download/MFRC522-python/MFRC522.py", line 112, in __init__
GPIO.setmode(GPIO.BOARD)
AttributeError: 'module' object has no attribute 'setmode'






해결 방법
sudo easy_install -U RPi.GPIO 이 명령어를 실행해서 RPI.GPIO를 설치합니다


$sudo easy_install -U RPi.GPIO
Searching for RPi.GPIO
Reading http://pypi.python.org/simple/RPi.GPIO/
Best match: RPi.GPIO 0.5.11
Downloading https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz#md5=9dc3dab6ce2b7ccb833a866efb392821
Processing RPi.GPIO-0.5.11.tar.gz
Running RPi.GPIO-0.5.11/setup.py -q bdist_egg --dist-dir /tmp/easy_install-IOIu1H/RPi.GPIO-0.5.11/egg-dist-tmp-yky5fe
zip_safe flag not set; analyzing archive contents...
Removing RPi.GPIO 0.1.0 from easy-install.pth file
Adding RPi.GPIO 0.5.11 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/RPi.GPIO-0.5.11-py2.7-linux-armv6l.egg
Processing dependencies for RPi.GPIO

Finished processing dependencies for RPi.GPIO 






에러를 해결후 잘 동작함


$sudo python Read.py
Welcome to the MFRC522 data read example
Press Ctrl-C to stop.
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Card detected
Card read UID: 23,101,85,197
Size: 8
Sector 8 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

^CCtrl+C captured, ending read.

 




신고





Posted by 파란물

티스토리 툴바