0
我有一個RPI 2(以像素運行raspbian傑西)模塊,只是試圖安裝的GPIO模塊:的Python +樹莓派不能導入GPIO沒有名爲_GPIO
我已經下載並安裝從源頭上。然後我發出命令:
[email protected]:python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
所以後來我嘗試使用sudo:
[email protected]:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
然後我刪除從蟒蛇的模塊,並安裝它再次使用PIP:
[email protected]:sudo pip install RPi.GPIO
[email protected]:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
然後我從python中刪除模塊,並使用apt-get再次安裝它:
[email protected]:sudo apt-get update
[email protected]:sudo apt-get -y install python-rpi.gpio
[email protected]:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
它似乎與安裝方法無關,所以我認爲這是與Raspbian Jessie +像素或python-gpio的當前版本中斷/不兼容有關。
它很奇怪,因爲我沒有導入「_GPIO」,我導入了「GPIO」,這表明我的python語法不是罪魁禍首。
有人請推薦我應該嘗試下一個?
我還在Google上搜索了this exact error,得到1個結果沒有幫助。
感謝,
你是完全正確的!事實證明,在我下載源文件並導航到setup.py所在的目錄後,我在啓動python時並沒有真正離開該目錄,並且提到它包含衝突文件。一旦我從另一個目錄中的另一個shell運行python,模塊導入就很好。謝謝! – Logic1