我的系统是Ubuntu 16.04。
~$ python3 -V
Python 3.6.5 :: Anaconda, Inc.
~$ python -V
Python 3.6.5 :: Anaconda, Inc.
我曾经对rm -f
做过一些愚蠢的事情,根据this删除了一些较低版本的python。然后我遇到了许多无法解决的错误。
我已经安装了什么:
~$ whereis python
python: /usr/bin/python3.5 /usr/bin/python3.5m /usr/lib/python2.7 /usr/lib/python3.5 /etc/python3.6 /etc/python2.7 /usr/local/lib/python2.7 /usr/local/lib/python3.5 /home/wxf/anaconda3/bin/python3.6 /home/wxf/anaconda3/bin/python3.6-config /home/wxf/anaconda3/bin/python3.6m-config /home/wxf/anaconda3/bin/python /home/wxf/anaconda3/bin/python3.6m
安装某些软件包时出现的错误,例如:
sudo apt install devscripts
输出:
~$ sudo apt install devscripts
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:
devscripts : Depends: python3:any (>= 3.3.2-2~)
Recommends: dctrl-tools
Recommends: dput or
dupload but it is not going to be installed
Recommends: libdistro-info-perl but it is not going to be installed
Recommends: lintian but it is not going to be installed
Recommends: patchutils
Recommends: python3-debian (>= 0.1.15) but it is not going to be installed
Recommends: python3-magic but it is not going to be installed
Recommends: wdiff but it is not going to be installed
dh-python : Depends: python3:any (>= 3.3.2-2~)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
我尝试remove all python,但仍然遇到相同的依赖项错误。
如果我apt-get -f install xxxx
~$ sudo apt-get -f install python3
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python3-doc python3-tk python3-venv
The following NEW packages will be installed:
python3
0 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.
4 not fully installed or removed.
Need to get 0 B/8,710 B of archives.
After this operation, 68.6 kB of additional disk space will be used.
Setting up python3.5-minimal (3.5.2-2ubuntu0~16.04.4) ...
# 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 0x00007f29be846700 (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-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
或没有包名称
~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
python3
Suggested packages:
python3-doc python3-tk python3-venv
The following NEW packages will be installed:
python3
0 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.
4 not fully installed or removed.
Need to get 0 B/8,710 B of archives.
After this operation, 68.6 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3.5-minimal (3.5.2-2ubuntu0~16.04.4) ...
# 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 0x00007fc90fdb7700 (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-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
递归发生依赖关系问题
~$ sudo apt-get -f install python3.5-minimal
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.5-minimal is already the newest version (3.5.2-2ubuntu0~16.04.4).
python3.5-minimal set to manually installed.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
dh-python : Depends: python3:any (>= 3.3.2-2~)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).