我从/usr/lib中删除了python3.9文件夹,并且无法再次安装它

我从/usr/lib中删除了python3.9文件夹,并且无法再次安装它

我犯了一个愚蠢的错误,从 /usr/bin 以及其他文件夹中删除了 python3.9 文件夹(这是一个很长的故事,为什么我这样做)。

当我尝试通过运行重新安装它时,sudo apt install python3.9我在屏幕截图中看到了这种错误。

重新安装python3.9时出错

我不知道这个“blueman”是什么,所以我需要一些帮助来解决它,因为我想要回我的python,但我不知道该怎么做。

整个输出:

[sudo] password for yahia: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3.9 is already the newest version (3.9.1-4).
The following packages were automatically installed and are no longer required:
  libaom0:i386 libcodec2-0.9 libcodec2-0.9:i386 libdav1d4:i386
  libdbusmenu-qt5-2 libjs-excanvas libjs-jquery-flot
  libpcre3:i386 libvpx6:i386 libwavpack1:i386 libx264-160:i386
  libx265-192:i386
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2343 not upgraded.
1 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 blueman (2.1.4-1+b1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/bin/python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python39.zip',
    '/usr/lib/python3.9',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fd8882db740 (most recent call first):
<no Python frame>
dpkg: error processing package blueman (--configure):
 installed blueman package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 blueman
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

系统仍认为python3.9已安装:

python3.9 is already the newest version (3.9.1-4).

如果您删除了文件而不删除程序包,则这是有意义的。因此,您需要明确地重新安装它:

sudo apt reinstall python3.9

根据您删除的其他文件,您可能还需要重新安装其他软件包。以下是重新安装已安装的所有 Python 包的方法:

sudo apt reinstall $(dpkg-query -W \*python\* | awk '$2 { print $1 }')

相关内容