簡體   English   中英

如何在 ubuntu 上修復 python3

[英]How to fix python3 on ubuntu

為了刪除舊版本的 python,我刪除了一些重要的東西,但現在沒有任何效果。

> python3
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 = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/home/karm/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/home/karm/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/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 0x00007f44dad8e740 (most recent call first):
<no Python frame>

其中 python 的whereis python

python: /usr/bin/python3.9 /usr/bin/python2.7 /usr/bin/python /usr/bin/python3.8-config /usr/bin/python3.8 /etc/python3.9 /etc/python2.7 /etc/python /etc/python3.8 /usr/include/python2.7 /usr/include/python3.8 /usr/share/python /home/karm/bin/python

當我運行export PYTHONHOME = /usr/export PYTHONHOME = /usr/bin/python3.9時,這些字段是固定的,但它不起作用。

當我運行sudo apt install -f時, output 是

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 47.6 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 python3 amd64 3.8.2-0ubuntu2 [47.6 kB]
Fetched 47.6 kB in 1s (77.5 kB/s) 
dpkg: error processing package python3 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 python3
E: Sub-process /usr/bin/dpkg returned an error code (1)

它不允許我做任何事情。 有沒有辦法在不從引導驅動器重新安裝操作系統的情況下解決這些問題?

問題是 Python 沒有完全安裝或移除。 我自己從來沒有遇到過這個問題,但你可以在這里檢查一下,看看這是否有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM