更新管理器无法正常工作“ImportError:没有名为‘codecs’的模块”

更新管理器无法正常工作“ImportError:没有名为‘codecs’的模块”

每当我尝试时sudo update-manager它都会返回:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "/usr/lib/python3.4/encodings/__init__.py", line 31, in <module>
ImportError: No module named 'codecs'

我尝试了以下命令:

sudo apt-get update # no errors
sudo apt-get clean # no errors
sudo apt-get install -fy # same error
sudo apt-get install --reinstall python3 # same error
sudo apt-get install --reinstall dpkg apt update-manager python # same error
sudo apt-get autoremove # same error
sudo apt-get upgrade # same error
sudo apt-get install --reinstall python3.4 #E: Internal Error, No file name for python3.4:amd64
sudo apt-get install python3.4 # same error (Dependency problems )
python --version #Python 2.7.6
sudo apt-get -f install # same error (Dependency problems )

我没有修改该__ init __.py文件。

这是一个完整的错误:

$ sudo apt-get -f install
[sudo] password for user: 
Building dependency tree                  
Reading state information... 
After this operation, 0 B of additional disk space will be used.
Setting up python3.4 (3.4.0-2ubuntu1) ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "/usr/lib/python3.4/encodings/__init__.py", line 31, in <module>
ImportError: No module named 'codecs'
Aborted (core dumped)
dpkg: error processing package python3.4 (--configure):
 subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of python3:
 python3 depends on python3.4 (>= 3.4.0-0~); however:
  Package python3.4 is not configured yet.

dpkg: error processing package python3 (--configure):
 dependency problems - leaving unconfigured
Setting up screen-resolution-extra (0.17.1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                          Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "/usr/lib/python3.4/encodings/__init__.py", line 31, in <module>
ImportError: No module named 'codecs'
Aborted (core dumped)
dpkg: error processing package screen-resolution-extra (--configure):
 subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of update-manager:
 update-manager depends on python3; however:
  Package python3 is not configured yet.
 update-manager depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package update-manager (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 python3.4
 python3
 screen-resolution-extra
 update-manager
E: Sub-process /usr/bin/dpkg returned an error code (1)

我正在使用 Ubuntu 14.04 LTS。

答案1

如果您的文件系统已损坏,则可能会发生这种情况。检查日志以获取提示,并查看内部/lost+found。解决方案是重新安装包含缺失模块的软件包。

找到提供此文件的 Ubuntu 包:

dpkg -S /usr/lib/python3.4/codecs.py

重新安装包:

sudo apt-get install --reinstall libpython3.4-minimal

此外,重新安装提供在lost+found

相关内容