![ImportError:Ubuntu 16.04 上没有名为“encodings”的模块](https://linux22.com/image/925049/ImportError%EF%BC%9AUbuntu%2016.04%20%E4%B8%8A%E6%B2%A1%E6%9C%89%E5%90%8D%E4%B8%BA%E2%80%9Cencodings%E2%80%9D%E7%9A%84%E6%A8%A1%E5%9D%97.png)
我的 Ubuntu 16.04 有损坏的软件包和未满足的依赖项。我尝试按照建议使用以下方法修复系统:
sudo apt-get -f install
一旦我这样做了,我将安装以下软件包:
The following packages were automatically installed and are no longer required:
bridge-utils dh-python gir1.2-glib-2.0 libgirepository-1.0-1 libpython-all-dev libpython-dev libpython2.7 libpython2.7-dev pigz python-all python-apt-common python2.7-dev
python3 python3-minimal python3.5 python3.5-minimal ubuntu-fan
Use 'sudo apt autoremove' to remove them.
继续安装后,出现以下错误:
Do you want to continue? [Y/n]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LC_TERMINAL_VERSION = "3.3.9",
LC_TERMINAL = "iTerm2",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up python3.5-minimal (3.5.2-2ubuntu0~16.04.9) ...
# Empty sitecustomize.py to avoid a dangling symlink
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f5fe3a58700 (most recent call first):
Aborted
dpkg: error processing package python3.5-minimal (--configure):
subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of python3-minimal:
python3-minimal depends on python3.5-minimal (>= 3.5.1-2~); however:
Package python3.5-minimal is not configured yet.
dpkg: error processing package python3-minimal (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3.5-minimal
python3-minimalE: Sub-process /usr/bin/dpkg returned an error code (1)
我尝试了建议的解决方案,设置PYTHONHOME
并PYTHONPATH
export PYTHONPATH=/usr/local/lib/python3.5/
export PYTHONHOME=/usr/local/lib/python3.5/
但这不起作用。然后我也尝试取消设置这些环境变量,但也有同样的效果。
因为这是共享主机。我检查了以下内容:
$which python
$which python3
/usr/local/bin/python3
$which python2
/usr/bin/python2
$ python -V
Python 3.6.4
是否需要清理并重置系统?或者完全卸载 python,但我读到过某处,这可能会导致系统无法使用。
我的 Ubuntu 版本:
$cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"