検索

ホームページ  >  に質問  >  本文

python - Ubuntu16.04:The following packages have unmet dependencies?

最近不知道设置了什么,现在在ubuntu16.04上使用apt安装软件都失败:

$ sudo apt-get upgrade                                                                                                                                   
Reading package lists... Done
Building dependency tree 
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libglib2.0-dev : Depends: libglib2.0-0 (= 2.48.1-1~ubuntu16.04.1) but 2.48.2-0ubuntu1 is installed
                  Depends: libglib2.0-bin (= 2.48.1-1~ubuntu16.04.1)
E: Unmet dependencies. Try using -f.

ps: sudo apt install ipython也是报同样的错误

然后我按照提示进行修复:

$ sudo apt-get -f install
Extracting templates from packages: 100%
Preconfiguring packages ...
dpkg: error processing package libglib2.0-dev (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
Errors were encountered while processing:
 libglib2.0-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)

准备卸载libglib2.0-dev,却无法卸载,而且报错信息和上面一样,提示reinstall,但是apt命令没有reinstall参数

$ sudo apt-get remove libglib2.0-dev
...
After this operation, 10.5 MB disk space will be freed.
Do you want to continue? [Y/n] y
dpkg: error processing package libglib2.0-dev (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
Errors were encountered while processing:
 libglib2.0-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)

libglib2.0-dev处于bad inconsistent state所以要reinstall,但是却无法卸载那么该怎么进行reinstall,google以及在其他社区找了很久也没找到答案,请问这是什么原因?


补充

$ sudo apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libglib2.0-dev : Depends: libglib2.0-0 (= 2.48.1-1~ubuntu16.04.1) but 2.48.2-0ubuntu1 is installed
                  Depends: libglib2.0-bin (= 2.48.1-1~ubuntu16.04.1)
E: Unmet dependencies. Try using -f.

解决方案

之前google的姿势不对,问题的关键是 package is in a very bad inconsistent state; you should reinstall it before attempting a removal

参考资料强制卸载sudo dpkg --remove --force-remove-reinstreq libglib2.0-dev,但是又出现了新的问题,由于包不兼容python3,所以还要sudo ln -s /usr/bin/python2.7 /usr/bin/python,这样一来就只能使用python2.7,然后各种软件配置重新改。

比如youcompleteme要改成python3等等。

let g:ycm_server_python_interpreter = '/usr/bin/python3'
let g:ycm_python_binary_path = '/usr/bin/python3'
天蓬老师天蓬老师2807日前1314

全員に返信(1)返信します

  • 巴扎黑

    巴扎黑2017-04-18 10:18:23

    libglib2.0-dev は libglib2.48.1-1 と libglib2.0-bin に依存します

    ただし、お使いのシステムには、上位バージョンである libglib2.48.2-0 > 2.48.1-1 がすでにインストールされています

    libglib2.48.2-0をアンインストールし、sudo apt-get install package=versionコマンドを使用して指定されたバージョンのlibglibをインストールします

    返事
    0
  • キャンセル返事