我在 ubuntu 18.04 系统上安装了多个 python,并尝试卸载所有必需的 python,然后正确地重新安装 python3.6
所以我删除了列出的所有文件夹whereis python
,这可能是一个坏主意。
现在如果我运行sudo apt-get install python3.6
它会返回
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.6 is already the newest version (3.6.5-3).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3.6-minimal (3.6.5-3) ...
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
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f814f83c740 (most recent call first):
Aborted
dpkg: error processing package python3.6-minimal (--configure):
installed python3.6-minimal package post-installation script subprocess returned error exit status 134
Setting up python-minimal (2.7.15~rc1-1) ...
/var/lib/dpkg/info/python-minimal.postinst: 4: /var/lib/dpkg/info/python-minimal.postinst: python2.7: not found
dpkg: error processing package python-minimal (--configure):
installed python-minimal package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python3.6:
python3.6 depends on python3.6-minimal (= 3.6.5-3); however:
Package python3.6-minimal is not configured yet.
dpkg: error processing package python3.6 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3.6-dev:
python3.6-dev depends on python3.6 (= 3.6.5-3); however:
Package python3.6 is not configured yet.
dpkg: error processing package python3.6-dev (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3.6-minimal
python-minimal
python3.6
python3.6-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
然后我尝试使用更新最小包,sudo apt-get install -f --reinstall python3.6-minimal
但返回
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for python3.6-minimal:amd64
我并不是一个经验丰富的 Linux 用户,所以我在这里陷入了困境。有人知道如何修复我的 Python 安装吗?
答案1
dpkg:处理软件包 python3.6-minimal 时出错(--configure):
dpkg:处理软件包 python3.6 时出错(--configure):
dpkg:处理软件包 python3.6-dev 时出错(--configure):
您有 3 个 dpkg 包错误需要重新配置,需要执行以下操作之一
sudo dpkg --configure -a
我发现你有 4 个包未升级
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
确保所有软件包都已更新并升级,运行
sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove
如果输出日志显示
Errors were encountered while processing:
python3.6-minimal
python-minimal
python3.6
python3.6-dev
尝试输入sudo apt-get install --fix-broken
如果在处理该包时仍然遇到错误,请尝试清除并删除所有 python,然后重新安装,然后按照
sudo apt-get purge python* && sudo apt-get autoclean && sudo apt-get install python*
希望这可以帮助。
答案2
我遇到了同样的问题,并能够通过以下方式解决这里进而这里。除非我用 下载它们然后用 安装它们,否则使用apt install
或apt purge
然后和 ...的任何解决方案都对我不起作用。以下方法对我有用:apt autoremove
apt download
dpkg -i
sudo apt-get download python3 python3.6 python3-minimal python3.6-minimal libpython3.6-minimal
sudo dpkg -i *python3*.deb
这里我收到一个错误,FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.6/__phello__.foo.py'
我可以用它来解决它:
sudo apt-get download libpython3.6-stdlib
sudo dpkg -i libpython3.6-stdlib*
此后,所有依赖于默认设置(难以安装)的东西都可以正常python3.6-minimal
工作。例如,在此之前我无法安装,ufw
但在此之后我可以。