解決樹莓派中python3無法import模組RPi.GPIO的問題辦法
[email protected]:~ $ python3
Python 3.6.4 (default, Apr 8 2018, 18:42:32)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'GPIO'
顯示python3裡面沒有RPi.GPIO,但是python2.7裡面有
[email protected]:~/GPIOtest $ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO
>>>
思來想去,還是pip來安裝吧
[email protected]:~/GPIOtest $ sudo pip3 install RPi.GPIO
Collecting RPi.GPIO
Downloading RPi.GPIO-0.6.3.tar.gz
Installing collected packages: RPi.GPIO
Running setup.py install for RPi.GPIO ... done
Successfully installed RPi.GPIO-0.6.3
[email protected]:~/GPIOtest $ python3
Python 3.6.4 (default, Apr 8 2018, 18:42:32)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO
>>>
yeah~ 現在可以用了。。。