pi@raspberrypi:~ $ 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 "
ModuleNotFoundError: No module named 'GPIO'
显示python3里面没有RPi.GPIO,但是python2.7里面有
pi@raspberrypi:~/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来安装吧
pi@raspberrypi:~/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
pi@raspberrypi:~/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~ 现在可以用了。。。