How to install Python3.12 within POP!_OS Flatpak VSCodium and change its python interpreter version to Python3.12?

208 Views Asked by At

Problem & TLDR

Hello! I recently switched from Windows to POP!_OS. I am not too familiar with Linux and Python but want to learn it.

I am having trouble with changing Flatpak VSCodium's Python interpreter version. Flatpak VSCodium's default python version is python 3.11.7 64-bit which I have not manually installed into my POP!_OS linux distribution system nor do I see it anywhere in my home directory. Python3.10 is installed by default when I installed POP!_OS. I installed Python3.12 to POP!_OS with virtualvenv however I still cannot change Flatpak VSCodium's Python interpreter version from its default Python3.11 to my installed Python3.12 even with a virtual environment folder. Flatpak may be the root cause of the issue however I am not sure. How may I resolve this issue?

I just want to install and use the latest Python version and program with tkinter.

How I installed:

First I installed Python3.12 by downloading deadsnakes with this POP!_OS default terminal command line sudo add-apt-repository ppa:deadsnakes/nightly -y. I accidentally installed the nightly version of Python3.12. However I did follow the steps to install Python3.12 successfully to my POP!_OS System with this link: https://www.linuxcapable.com/install-python-3-12-on-ubuntu-linux/#Install-PIP-with-Python-312-on-Ubuntu-2204-or-2004.

Next I installed pip via the command line sudo apt install python3-pip.

After that, I installed VSCodium by clicking install within POP!_SHOP. I installed the Python extension when for VSCodium as well.

I made a parent folder called vscodium_workspace under my user folder. I made a child folder that stores python files for VSCodium called pythontest.

I followed the instructions from this website for Python3.12 (https://tellor.io/blog/how-to-install-python-3-9-and-venv-on-ubuntu/) to set up a virtual environment within my vscodium_workspace folder adjacent to pythontest called vsenv. vsenv has Python 3.12 installed.

What I have tried:

I have identified the python versions that I have from my POP!_OS default terminal (Python3.10 && Python3.12) and VSCodium (Python3.11) and where those python versions are.

Terminal Python version VSCodium Python version environment Python version

I have tried setting a virtual environment with Python3.12 installed and restarting VSCodium. However I still cannot find Python3.12 as a python interpreter even though I have it installed. VSCodium defaults to Python3.11.

vsenv files

I get an output error in VSCodium every time I try to switch the python interpreter. It seems as if VSCodium cannot recognize Python3.12.

VSCodium Error Messages

VSCodium Output:

2023-12-31 16:26:13.756 [warning] [Error: Command failed: /run/user/1000/doc/b6fda2f6/python3.12 -I /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/get_output_via_markers.py /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/interpreterInfo.py
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 = '/run/user/1000/doc/b6fda2f6/python3.12'
  isolated = 1
  environment = 0
  user site = 0
  safe_path = 1
  import site = 1
  is in build tree = 0
  stdlib dir = '/usr/lib/python3.12'
  sys._base_executable = '/run/user/1000/doc/b6fda2f6/python3.12'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib'
  sys.executable = '/run/user/1000/doc/b6fda2f6/python3.12'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python312.zip',
    '/usr/lib/python3.12',
    '/usr/lib/python3.12/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 0x00007a67f433a040 (most recent call first):
  <no Python frame>

    at ChildProcess.exithandler (node:child_process:430:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/run/user/1000/doc/b6fda2f6/python3.12 -I /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/get_output_via_markers.py /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/interpreterInfo.py'
}
2023-12-31 16:26:13.760 [info] > /run/user/1000/doc/b6fda2f6/python3.12 ~/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/get_output_via_markers.py ~/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/interpreterInfo.py
2023-12-31 16:26:13.796 [error] [Error: Command failed: /run/user/1000/doc/b6fda2f6/python3.12 /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/get_output_via_markers.py /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/interpreterInfo.py
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 = '/run/user/1000/doc/b6fda2f6/python3.12'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/usr/lib/python3.12'
  sys._base_executable = '/run/user/1000/doc/b6fda2f6/python3.12'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib'
  sys.executable = '/run/user/1000/doc/b6fda2f6/python3.12'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python312.zip',
    '/usr/lib/python3.12',
    '/usr/lib/python3.12/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 0x00007012d7637040 (most recent call first):
  <no Python frame>

    at ChildProcess.exithandler (node:child_process:430:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:322:12)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/run/user/1000/doc/b6fda2f6/python3.12 /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/get_output_via_markers.py /home/zhen/.var/app/com.vscodium.codium/data/codium/extensions/ms-python.python-2023.20.0-universal/pythonFiles/interpreterInfo.py'
}
2023-12-31 16:26:13.798 [error] Unable to start Jedi language server as a valid interpreter is not selected

I have tried restarting my POP!_OS System and sudo apt update.

I have tried reinstalling POP!_OS.

I found out that Flatpak VSCodium is ran inside a container so that it has limited access to the rest of my system: https://github.com/flathub/com.vscodium.codium#host-shell and is sandboxed https://docs.flatpak.org/en/latest/sandbox-permissions.html.

So I ask ChatGPT for help but I could not find much of an answer beside finding the Flatpak VSCodium ID.

zhen@pop-os:~/vscodium_workspace$ flatpack list
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
zhen@pop-os:~/vscodium_workspace$ cd /
zhen@pop-os:/$ flatpak list
Name        Application ID               Version      Branch      Installation
Discord     com.discordapp.Discord       0.0.39       stable      user
VSCodium    com.vscodium.codium          1.85.1.23348 stable      user
Freedeskto… org.freedesktop.Platform     23.08.9      23.08       user
Mesa        …desktop.Platform.GL.default 23.3.1       23.08       user
Mesa (Extr… …desktop.Platform.GL.default 23.3.1       23.08-extra user
nvidia-545… …latform.GL.nvidia-545-29-06              1.4         user
Intel       …esktop.Platform.VAAPI.Intel              23.08       user
openh264    …eedesktop.Platform.openh264 2.1.0        2.2.0       user
Freedeskto… org.freedesktop.Sdk          23.08.9      23.08       user
Pop Gtk th… org.gtk.Gtk3theme.Pop-dark                3.22        user
zhen@pop-os:/$ flatpak info com.vscodium.codium

VSCodium - Code editing. Redefined. Telemetry less.

          ID: com.vscodium.codium
         Ref: app/com.vscodium.codium/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 1.85.1.23348
     License: MIT
      Origin: flathub
  Collection: org.flathub.Stable
Installation: user
   Installed: 342.6 MB
     Runtime: org.freedesktop.Sdk/x86_64/23.08
         Sdk: org.freedesktop.Sdk/x86_64/23.08

      Commit: b05e67034a507910ca4ace4e03e00550abd09aa59de143facb2a8418c505bc5c
      Parent: c74719ca5d569d7befd8c731f49eba22f39b3a73837730cd7d8bbe15a1aef5e2
     Subject: :tada: Update Codium (a0c44587)
        Date: 2023-12-25 19:24:30 +0000

If you have any ideas how to solve my problem, it would be greatly appreciated. Happy New Year!

1

There are 1 best solutions below

0
Aspiring_Coder On

After some research, I deleted the Flatpak version of VSCodium and installed the Deb version of VSCodium by following the instructions via the official VSCodium page: https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo.

Due to Flatpak not sandboxing VSCodium like Flatpak, I was able to access my python versions and tkinter that I downloaded earlier.