Score:0

Ubuntu-23.04 version apt-get update not working (python3 error)

fi flag

I have new ubuntu system with version 23.04 and when i do sudo apt-get update I get the following output.

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/bin/python3'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/usr/lib/python3.11'
  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/python311.zip',
    '/usr/lib/python3.11',
    '/usr/lib/python3.11/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 0x00007fea58b1d040 (most recent call first):
  <no Python frame>
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'

I tried to then update all of my packages, including python, but when I performed apt-get update I get the following output and errors below

guiverc avatar
cn flag
Have you changed the default `python3` version, as front-end user tools like `apt` rely on the version being the system default. If you've changed default python, it's expected many Ubuntu tools (*those written to use python3 version*) will not work. Basic tools will still work, such as `wget` to download a package and `dpkg` to install, but user-front-end tools which are written in python3 won't work. Return the `python3` version to default. If you enter `python3 -V` what do you see?
Hannu avatar
ca flag
For normal (inexperienced) users, any updates to Ubuntu is best done using apt or apt-get (command line option) or other related system tools (e.g. `Software & Updates`, GUI), not by downloading random packages with home-brew install instructions.
karel avatar
sa flag
Does this answer your question? [Python broke somehow "Could not find platform independent libraries <prefix>"](https://askubuntu.com/questions/874763/python-broke-somehow-could-not-find-platform-independent-libraries-prefix)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.