Cursor 0.46.0 adds $PYTHONHOME to env with wrong value

Version:

➜ echo $PYTHONHOME
/tmp/.mount_cursoroNCRSv/usr/

When I look into $PYTHONHOME, it is a wrong value. It breaks lots of things starting from python

➜ python3
Fatal Python error: Failed to import encodings module
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007d4192a78740 (most recent call first):
  <no Python frame>

Please fix this. Thank you.

Version: 0.46.0
VSCode Version: 1.96.2
Commit: aff57e1d9a74ed627fb5bd393e347079514436a0
Date: 2025-02-21T04:49:24.841Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 5.10.0-23-amd64

env | grep PYTHONHOME
PYTHONHOME=/tmp/.mount_cursorhmX5gQ/usr/

Download and install again from the official website, do not use the check for update feature in the IDE to update

But that downgrades cursor. Any workaround that would let us keep 0.46.0?

There is definitely something wrong with how paths are handled. I managed to solve it in the launcher, but today I hit the issue with python too and I am a bit afraid much more things got broken, waiting to be discovered.

This didn’t work for me…

Good workaround here:

export “PYTHONHOME=”

you can also add it to your launch config

{
    "configurations": [
        {
            ...
            "env": {
               ...
                "PYTHONHOME": ""
            }
        }
    ]
}

For me the only workaround that worked was downgrading.

This comment has a link to the 0.45.14 appimage which fixes it

In Linux, I managed to fix this by rolling back to version 0.45.14 (I had the same issues even with 0.45.15, not only 0.46). I also used the script kindly provided by @Kirai and made a few modifications to make it work in Wayland (added the --ozone-platform=wayland option). For details see Installing command line launcher on Linux - #6 by Kirai

For Version Download Links see GitHub - oslook/cursor-ai-downloads: all cursor ai version download links, and some older versions offer a better user experience

So any response from the cursor team to fix this in future versions or are we all going to be stuck on version 0.45.x?

I downgraded to 0.45, but it got upgraded to 0.46.3 and the issue appeared again.

This bugs also effects all my extensions for linting, which makes the IDE unusable for me right now.
Ruff or Pylint throw errors like

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'

I worked on this for hours and somehow found a work around for me.
It’s happening because Cursor is forcing its own Python environment.

I simply added this to the bottom of my ~/.bashrc and restarted Cursor:

export PYTHONHOME=""
export PYTHONPATH=""

After doing that it worked with no errors, including showing proper linting.

How I figured it out:

When I unset the values manually in the terminal (in cursor), I could then run the file:

unset PYTHONHOME
unset PYTHONPATH
python3 main.py (or clicking the run button)

However, if I restarted Cursor or opened a new terminal and tried running the file again, it would show the same error:

Python path configuration:
  PYTHONHOME = '/tmp/.mount_CursorXomwZv/usr/'
  PYTHONPATH = '/tmp/.mount_CursorXomwZv/usr/share/pyshared/:'
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1

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 0x000073646c2c9740 (most recent call first):
  <no Python frame>

So instead of having to unset the two values manually every time I ran my .py file, I just made it permanent by forcing those values to be unset by adding it to my ~/.bashrc and wallah!

Hope this helps someone!

I solved in terminal by adding in settings.json:

    "terminal.integrated.env.linux": {
        "PYTHONHOME": ""
    }