(Linux/ Ubuntu) Python not working in terminal

Thanks for reporting a bug you have found in Cursor!
Please add the following info to help us diagnose your issue:

:white_check_mark: Check the forum to ensure the issue hasn’t been reported already
couldn’t find anything…

:lady_beetle: Provide a clear description of the bug
Everything I do in the integrated Cursor terminal that has to do with Python, gives me an error (change environments with conda, running an interactive python, doing python -v)

(env-name) user-name:~/Documents/folder > python -v
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
import 'posix' # <class '_frozen_importlib.BuiltinImporter'>
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
# installing zipimport hook
import 'time' # <class '_frozen_importlib.BuiltinImporter'>
import 'zipimport' # <class '_frozen_importlib.FrozenImporter'>
# installed zipimport hook
Python path configuration:
  PYTHONHOME = '/tmp/.mount_cursorRLSqHl/usr/'
  PYTHONPATH = '/tmp/.mount_cursorRLSqHl/usr/share/pyshared/:'
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/tmp/.mount_cursorRLSqHl/usr/lib/python3.12'
  sys._base_executable = '/home/user-name/miniconda3/envs/env-name/bin/python'
  sys.base_prefix = '/tmp/.mount_cursorRLSqHl/usr/'
  sys.base_exec_prefix = '/tmp/.mount_cursorRLSqHl/usr/'
  sys.platlibdir = 'lib'
  sys.executable = '/home/user-name/miniconda3/envs/env-name/bin/python'
  sys.prefix = '/tmp/.mount_cursorRLSqHl/usr/'
  sys.exec_prefix = '/tmp/.mount_cursorRLSqHl/usr/'
  sys.path = [
    '/tmp/.mount_cursorRLSqHl/usr/share/pyshared',
    '/home/user-name/Documents/folder',
    '/tmp/.mount_cursorRLSqHl/usr/lib/python312.zip',
    '/tmp/.mount_cursorRLSqHl/usr/lib/python3.12',
    '/tmp/.mount_cursorRLSqHl/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
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1318, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'encodings'

:arrows_counterclockwise: Explain how to reproduce the bug (if known)
in the integrated terminal run: python -v
:camera: Attach screenshots or recordings (e.g., .jpg, .png, .mp4).
(copy pasted the error above)
:computer: Tell us your operating system and your Cursor version (e.g., Windows, 0.x.x).

Ubuntu 22.04.5 LTS

Version: 0.45.15
VSCode Version: 1.96.2
Commit: 73dd83bb6f8e3a3704ad8078a8e455ac6d4260d0
Date: 2025-02-22T10:33:24.556Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.8.0-52-generic

:no_entry_sign: Tell us if the issue stops you from using Cursor.
Yes, well i can use the system terminal I guess…

1 Like

Facing the exact same issue with exact same versions of everything. The very first version of Cursor I’ve ever tried, pretty bad experience so far haha

I was able to run Python in the IDE terminal after unset PYTHONPATH unset PYTHONHOME but the Run/Debug features are still broken, debugpy configurations don’t work

1 Like

It might be breaking black linter as well right?

I don’t understand if this bug was logged or not by Cursor’s team?

Having the same issue in 0.46.2, installed with AppImage on Fedora 40.

Cursor:

Version: 0.46.2
VSCode Version: 1.96.2
Commit: 84b9c6d907219bb8c2874f299540eb6a079187a0
Date: 2025-02-23T01:17:13.048Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.12.13-100.fc40.x86_64

Linux version :

 $ uname -a
Linux localhost.localdomain 6.12.13-100.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Feb  8 17:10:01 UTC 2025 x86_64 GNU/Linux

 $ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="40 (Workstation Edition)"
ID=fedora
VERSION_ID=40
VERSION_CODENAME=""
PLATFORM_ID="platform:f40"
PRETTY_NAME="Fedora Linux 40 (Workstation Edition)"

virtualenv version:

 $ source virtualenv/bin/activate
 $ python --version
Python 3.12.8

System python:

$ which python
/usr/bin/python

$ python --version
Python 3.12.8

Python and flake8 work correctly inside the shell with alex-petrenko’s workaround. However that was unable to fix flake8, pylint, and a few other issues I was seeing.

jlcheng suggestion at
Fatal Python error: Failed to import encodings module - #8 by jlcheng fixed all my issues.