jlcheng
February 23, 2025, 12:12am
1
I am using version Cursor-0.45.15-73dd83bb6f8e3a3704ad8078a8e455ac6d4260d1.deb.glibc2.25-x86_64.AppImage
with
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS (beaver-three-eyed-raven X92)"
When using VS Code, I can open the editor, run a terminal, and run python.
When using Cursor, I get an error
Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fdb63465200 (most recent call first):
<no Python frame>
Furthermore, Python simply doesn’t work in Cursor.
3 Likes
jlcheng
February 23, 2025, 1:54am
2
To add more context, I can see unusual outputs in the OUTPUT tab:
2025-02-22 17:52:25.411 [info] Name: isort
2025-02-22 17:52:25.411 [info] Module: isort
2025-02-22 17:52:25.411 [info] Python extension loading
2025-02-22 17:52:25.411 [info] Waiting for interpreter from python extension.
2025-02-22 17:52:25.510 [info] No interpreter found from setting isort.interpreter
2025-02-22 17:52:25.510 [info] Getting interpreter from ms-python.python extension for workspace /home/jcheng/privprjs/pymono
2025-02-22 17:52:25.510 [info] Python extension loaded
2025-02-22 17:52:25.511 [info] Interpreter from ms-python.python extension for /home/jcheng/privprjs/pymono: /home/jcheng/.pyenv/versions/pymono/bin/python
2025-02-22 17:52:25.511 [info] No interpreter found from setting isort.interpreter
2025-02-22 17:52:25.511 [info] Getting interpreter from ms-python.python extension for workspace /home/jcheng/privprjs/pymono
2025-02-22 17:52:25.512 [info] Interpreter from ms-python.python extension for /home/jcheng/privprjs/pymono: /home/jcheng/.pyenv/versions/pymono/bin/python
2025-02-22 17:52:25.581 [info] Server run command: /home/jcheng/.pyenv/versions/pymono/bin/python /home/jcheng/.cursor/extensions/ms-python.isort-2023.10.1/bundled/tool/lsp_server.py
2025-02-22 17:52:25.582 [info] Server: Start requested.
2025-02-22 17:52:25.674 [info] [Error - 5:52:25 PM] Client isort: connection to server is erroring. Shutting down server.
2025-02-22 17:52:25.675 [info] [Error - 5:52:25 PM] Stopping server failed
2025-02-22 17:52:25.675 [info] Error: Client is not running and can't be stopped. It's current state is: starting
at D.shutdown (/home/jcheng/.cursor/extensions/ms-python.isort-2023.10.1/dist/extension.js:1:148489)
at D.stop (/home/jcheng/.cursor/extensions/ms-python.isort-2023.10.1/dist/extension.js:1:148070)
at D.stop (/home/jcheng/.cursor/extensions/ms-python.isort-2023.10.1/dist/extension.js:1:310084)
at D.handleConnectionError (/home/jcheng/.cursor/extensions/ms-python.isort-2023.10.1/dist/extension.js:1:154577)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2025-02-22 17:52:25.676 [info] [Error - 5:52:25 PM] Server initialization failed.
2025-02-22 17:52:25.676 [info] Message: write EPIPE
Code: -32099
2025-02-22 17:52:25.676 [info] [Error - 5:52:25 PM] isort client: couldn't create connection to server.
2025-02-22 17:52:25.676 [info] Message: write EPIPE
Code: -32099
2025-02-22 17:52:25.677 [error] Server: Start failed: Error: write EPIPE
2025-02-22 17:52:25.678 [info] [Info - 5:52:25 PM] Connection to server got closed. Server will restart.
2025-02-22 17:52:25.678 [info] true
2025-02-22 17:52:25.720 [info] Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f8a1eb15200 (most recent call first):
<no Python frame>
2025-02-22 17:52:25.721 [info] [Error - 5:52:25 PM] Server initialization failed.
2025-02-22 17:52:25.721 [info] Message: Cannot call write after a stream was destroyed
Code: -32099
2025-02-22 17:52:25.721 [info] [Error - 5:52:25 PM] isort client: couldn't create connection to server.
2025-02-22 17:52:25.721 [info] Message: Cannot call write after a stream was destroyed
Code: -32099
2025-02-22 17:52:25.721 [info] [Error - 5:52:25 PM] Restarting server failed
2025-02-22 17:52:25.721 [info] Message: Cannot call write after a stream was destroyed
Code: -32099
2025-02-22 17:52:25.721 [info] [Info - 5:52:25 PM] Connection to server got closed. Server will restart.
2025-02-22 17:52:25.721 [info] true
2025-02-22 17:52:26.479 [info] Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f48f3b3f200 (most recent call first):
<no Python frame>
2025-02-22 17:52:26.553 [info] Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f83304df200 (most recent call first):
<no Python frame>
2025-02-22 17:52:26.554 [info] [Error - 5:52:26 PM] Server initialization failed.
2025-02-22 17:52:26.554 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.554 [info] [Info - 5:52:26 PM] Connection to server got closed. Server will restart.
2025-02-22 17:52:26.554 [info] true
2025-02-22 17:52:26.554 [info] [Error - 5:52:26 PM] isort client: couldn't create connection to server.
2025-02-22 17:52:26.554 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.597 [info] Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fd1045e5200 (most recent call first):
<no Python frame>
2025-02-22 17:52:26.597 [info] [Error - 5:52:26 PM] Server initialization failed.
2025-02-22 17:52:26.597 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.598 [info] [Info - 5:52:26 PM] Connection to server got closed. Server will restart.
2025-02-22 17:52:26.598 [info] true
2025-02-22 17:52:26.598 [info] [Error - 5:52:26 PM] isort client: couldn't create connection to server.
2025-02-22 17:52:26.598 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.598 [info] [Error - 5:52:26 PM] Restarting server failed
2025-02-22 17:52:26.598 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.628 [info] Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fd582d2a200 (most recent call first):
<no Python frame>
2025-02-22 17:52:26.629 [info] [Error - 5:52:26 PM] Server initialization failed.
2025-02-22 17:52:26.629 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.629 [info] [Error - 5:52:26 PM] The isort server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
2025-02-22 17:52:26.629 [info] [Error - 5:52:26 PM] isort client: couldn't create connection to server.
2025-02-22 17:52:26.629 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2025-02-22 17:52:26.629 [info] [Error - 5:52:26 PM] Restarting server failed
2025-02-22 17:52:26.629 [info] Message: Pending response rejected since connection got disposed
Code: -32097
Which again suggests the Cursor process cannot invoke Python–likely due to the customized $PYTHONHOME environment variable that Cursor uses.
2 Likes
jlcheng
February 23, 2025, 2:17am
3
This is what happens when I try to create a virtual environment using Cursor’s graphical UI
2025-02-22 18:16:45.538 [info] Selected workspace /home/jcheng/privprjs/pymono for creating virtual environment.
2025-02-22 18:16:55.069 [info] Selected interpreter /usr/bin/python3 for creating virtual environment.
2025-02-22 18:17:02.494 [info] Running Env creation script: [
'/usr/bin/python3',
'/home/jcheng/.cursor/extensions/ms-python.python-2024.12.3-linux-x64/python_files/create_venv.py',
'--git-ignore',
'--requirements',
'/home/jcheng/privprjs/pymono/requirements.txt'
]
2025-02-22 18:17:02.494 [info] > /usr/bin/python3 ~/.cursor/extensions/ms-python.python-2024.12.3-linux-x64/python_files/create_venv.py --git-ignore --requirements ./requirements.txt
2025-02-22 18:17:02.495 [info] cwd: .
2025-02-22 18:17:02.503 [info] Python path configuration:
PYTHONHOME = '/tmp/.mount_cursorbVMFMG/usr/'
PYTHONPATH = '/tmp/.mount_cursorbVMFMG/usr/share/pyshared/:'
program name = '/usr/bin/p
2025-02-22 18:17:02.503 [info] ython3'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/usr/bin/python3'
sys.base_prefix = '/tmp/.mount_cursorbVMFMG/usr'
sys.base_exec_prefix = '/tmp/.mount_cursorbVMFMG/usr'
sys.platlibdir = 'lib'
sys.executable = '/usr/bin/python3'
sys.prefix = '/tmp/.mount_cursorbVMFMG/usr'
sys.exec_prefix = '/tmp/.mount_cursorbVMFMG/usr'
sys.path = [
'/tmp/.mount_cursorbVMFMG/usr/share/pyshared/',
'',
'/tmp/.mount_cursorbVMFMG/usr/lib/python310.zip',
'/tmp/.mount_cursorbVMFMG/usr/lib/python3.10',
'/tmp/.mount_cursorbVMFMG/usr/lib/python3.10/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 0x00007fae31a32740 (most recent call first):
<no Python frame>
2025-02-22 18:17:02.504 [error] Error while running venv creation script: undefined
2025-02-22 18:17:02.504 [error] Failed to create virtual environment with exitCode: 1
1 Like
I’m getting the exact same error here. Tried uninstalling/reinstalling extensions etc
echo $PYTHONPATH and go there… pyshared is not a directory.
tree /tmp/.mount_cursorXRStHb/usr/share/:
.
├── appdata
├── applications
├── bash-completion
├── cursor
├── icons
├── mime
├── pixmaps
└── zsh
Luny-S
February 24, 2025, 6:35pm
6
I have the same issue. I did upgrade to 0.45.15 today on Ubuntu 22.04 LTS.
Python path configuration:
PYTHONHOME = '/tmp/.mount_cursorCTSAPg/usr/'
PYTHONPATH = '/tmp/.mount_cursorCTSAPg/usr/share/pyshared/:'
program name = '/usr/bin/python3'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/usr/bin/python3'
sys.base_prefix = '/tmp/.mount_cursorCTSAPg/usr'
sys.base_exec_prefix = '/tmp/.mount_cursorCTSAPg/usr'
sys.platlibdir = 'lib'
sys.executable = '/usr/bin/python3'
sys.prefix = '/tmp/.mount_cursorCTSAPg/usr'
sys.exec_prefix = '/tmp/.mount_cursorCTSAPg/usr'
sys.path = [
'/tmp/.mount_cursorCTSAPg/usr/share/pyshared/',
'',
'/tmp/.mount_cursorCTSAPg/usr/lib/python310.zip',
'/tmp/.mount_cursorCTSAPg/usr/lib/python3.10',
'/tmp/.mount_cursorCTSAPg/usr/lib/python3.10/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 0x00007d90e6f2d740 (most recent call first):
<no Python frame>
Luny-S
February 24, 2025, 6:49pm
7
Found a solution that worked for me.
Today I might have messed something with registering AppImage as app so it appears on the launch bar.
I deleted my config and followed these instructions
jlcheng
February 24, 2025, 10:54pm
8
I ended up extracted the contents of the app image then running the squashfs-root/usr/bin/cursor
file within the AppImage directly.
Create a new, empty directory, e.g., $HOME/cursor-hack
Download the Cursor AppImage to the directory
Run
Cursor-${x_y_z}-${checksum}.deb..glibc2.25-x86_64.AppImage --appimage-extract
Run $HOME/cursor-hack/squashfs-root/usr/bin/cursor
If I were to run the AppImage directly, then I’d see this in the output panel
The expected output by extracting and accessing squashfs-root/usr/bin/cursor
It works for now, I think.
1 Like
az2
February 25, 2025, 12:39pm
9
I’m experiencing the same absolute same issue with Cursor 0.46.2 (AppImage) on Fedora 40.
I was unable to use flake8, and I had other minor issues as well.
Environment Details
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:
$ 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
Python Environments:
# Virtual Environment
$ source virtualenv/bin/activate
$ python --version
Python 3.12.8
# System Python
$ which python
/usr/bin/python
$ python --version
Python 3.12.8
For me jlcheng workaround works out of the box.
This issue might be the cause of (Linux/ Ubuntu) Python not working in terminal - #3 by azier
I had this issue as well. Fix that happened to work for me:
rm path/to/old-executable.AppImage
cd ~/.local/bin
wget https://downloader.cursor.sh/linux/appImage/x64 -O cursor.AppImage
chmod +x cursor.AppImage
I still have all my old chats and stuff too… which is nice.
Note, I didn’t track whether a version bumped between the re-install. But my Cursor is generally up to date because I always update when it notifies me of a new version.