1. 程式人生 > >樹莓派 E: Sub-process /usr/bin/dpkg returned an error code (1)解決方法

樹莓派 E: Sub-process /usr/bin/dpkg returned an error code (1)解決方法

當你在終端使用sudo apt-get install (檔名)-----安裝檔案時突然報錯:

E: Sub-process /usr/bin/dpkg returned an error code 

看看錯誤原因,裡面如果有:

Traceback (most recent call last):
  File "/usr/bin/apt-listchanges", line 29, in 
    import anydbm
ImportError: No module named 'anydbm'

則可能是因為你用的是Python3,而安裝的要求時用python2.7編譯,所以更改python的優先順序或許可以,

終端輸入命令:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 150

輸入命令sudo update-alternatives --config python可以檢視優先順序(如果優先順序數字越大則優先順序越高

到這裡再用apt-get試一試應該就不會報錯了。