cursor icon indicating copy to clipboard operation
cursor copied to clipboard

[Linux] Cannot use python scripts both in cursor IDE and Cursor Terminal : working command in system terminal does not work in cursor terminal, executable "sys.executable: /opt/cursor.appimage" replaces selected Python executable and blocks module imports

Open MarArMar opened this issue 1 year ago • 24 comments

I installed "lorem_text" python dependency

When I run a script using it, even when specifying the full path to my virtual env, cursor replaces the executable

If I print "sys.executable" it returns "/opt/cursor.appimage"

This is even with the executable correctly set in Cursor IDE, and all linters detecting the requirement

Step to reproduce on Linux :

  • Create virtual env
  • Install any dependency, example lorem_text
  • Run a script from terminal or from "play" button on top right of IDE using that dependency
  • The installed modules is not detected, script cannot run

Reproduction script :

import sys

print(f"sys.executable: {sys.executable}")

from lorem_text import lorem
❯ which python
/home/me/dev/PythonKit/.venv/bin/python
❯ which pip
/home/me/dev/PythonKit/.venv/bin/pip
❯ pip install lorem_text
Requirement already satisfied: lorem_text in ./.venv/lib/python3.11/site-packages (2.1)
Requirement already satisfied: Click>=7.0 in ./.venv/lib/python3.11/site-packages (from lorem_text) (8.1.7)
❯ /home/me/dev/PythonKit/.venv/bin/python /home/me/dev/PythonKit/app/scripts/contrib.py
sys.executable: /opt/cursor.appimage
Traceback (most recent call last):
  File "/home/me/dev/PythonKit/app/scripts/contrib.py", line 12, in <module>
    from lorem_text import lorem
ModuleNotFoundError: No module named 'lorem_text'

Operating System: TUXEDO OS 2 KDE Plasma Version: 5.27.10 KDE Frameworks Version: 5.114.0 Qt Version: 5.15.12 Kernel Version: 6.5.0-10040-tuxedo (64-bit) Graphics Platform: X11

MarArMar avatar Jun 08 '24 13:06 MarArMar

The same command

/home/me/dev/PythonKit/.venv/bin/python /home/me/dev/PythonKit/app/scripts/contrib.py

Work in system terminal but not in cursor IDE terminal, which is SUPER abnormal

MarArMar avatar Jun 08 '24 13:06 MarArMar

This is really blocking my workflow with Python on Cursor ATM

MarArMar avatar Jun 08 '24 14:06 MarArMar

I'm having the same problem, did you solve this?

runa avatar Sep 09 '24 17:09 runa

How can such a serious issue not be answered or fixed for 10 months?

johbub avatar Oct 17 '24 16:10 johbub

Maybe we can try debugging it together? Are you using a new project or importing an existing one (I've been using mine in VScode)? I'm running ubuntu here

runa avatar Oct 17 '24 18:10 runa

are you using zsh in the cursor terminal?

johbub avatar Oct 18 '24 07:10 johbub

yes!

changing to bash seems to solve the issue, right??

runa avatar Oct 18 '24 14:10 runa

Yep. I found like ~50 similar issues in this forum. all seem to be related to zsh. using bash solves all of them.

For others searching here, this solves:

  • python -m venv venv not working
  • python symlink to AppIMage problem
  • python module not found problem
  • active virtual env but python path is not correct

johbub avatar Oct 18 '24 14:10 johbub

Thanks! :)

On Fri, Oct 18, 2024 at 11:05 AM johbub @.***> wrote:

Yep. I found like ~50 similar issues in this forum. all seem to be related to zsh. using bash solves all of them.

For others searching here, this solves:

  • python -m venv venv not working
  • python symlink to AppIMage problem
  • python module not found problem
  • active virtual env but python path is not correct

— Reply to this email directly, view it on GitHub https://github.com/getcursor/cursor/issues/1484#issuecomment-2422556912, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOECTQMZMVCBOVC6PKPZLZ4EIQ7AVCNFSM6AAAAABJAAFTBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRSGU2TMOJRGI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Martin Sarsale http://www.linkedin.com/in/msarsale

runa avatar Oct 18 '24 14:10 runa

I am also experiencing this issue and can confirm that switching from zsh to bash resolves the issue. It'd be nice to get back to using zsh, though, this is a frustrating thing to debug for an IDE.

AustinDoolittle avatar Oct 30 '24 14:10 AustinDoolittle

By chance of debugging some code, I discovered that this alias solves the problem for me: alias python='/usr/bin/env python'. Something is broken in Cursor that this is not properly done, I think.

vitalwarley avatar Nov 04 '24 10:11 vitalwarley

#792 Same issue here. Over a year with no resolution. Using zsh with cursor is impossible with this bug

abarbadan avatar Dec 15 '24 02:12 abarbadan

This is blocking me from switching from vscode to cursor.

MauritsDescamps avatar Jan 09 '25 11:01 MauritsDescamps

This workaround works for me: import sys sys.path.append(f"venv/lib/python{sys.version_info.major}.{sys.version_info.minor}/site-packages")

The lines need to be run before you import anything that is in site-packages.

MikeBreytenbach avatar Jan 15 '25 13:01 MikeBreytenbach

Another way to walk around: use the remote ssh plugin to open your localhost folder in ssh, similar to how you are attaching cursor/vscode to a remote server (first make sure your ssh service is activated, can be checked by ssh localhost). In this case, you are only using a Cursor frontend and the cursor-server backend. zsh works well in this case

yihuai-gao avatar Jan 16 '25 20:01 yihuai-gao

moving to bash worked for me, dont waste your time

Kayaba-Attribution avatar Feb 11 '25 20:02 Kayaba-Attribution

It seems that the issue lies in the interaction between zsh and Cursor. I set the defaultProfile to tmux in the settings ( "terminal.integrated.defaultProfile.linux": "tmux") to isolate zsh, and it works fine now with zsh.

SkywalkerDarren avatar Feb 27 '25 12:02 SkywalkerDarren

It seems that the issue lies in the interaction between zsh and Cursor. I set the defaultProfile to tmux in the settings ( "terminal.integrated.defaultProfile.linux": "tmux") to isolate zsh, and it works fine now with zsh.

works !

aarunjith avatar Feb 27 '25 15:02 aarunjith

It seems that the issue lies in the interaction between zsh and Cursor. I set the defaultProfile to tmux in the settings ( "terminal.integrated.defaultProfile.linux": "tmux") to isolate zsh, and it works fine now with zsh.

For anyone struggling to know where to insert this setting and being confused by an existing VS Code installation: it should go in the ~/.config/Cursor/User/settings.json file, not in ~/.config/Code/User/settings.json. This is logical, however, it confused me a lot because whenever I would quick search for settings.json, the latter would pop up (for whatever reason).

grssnbchr avatar Mar 04 '25 08:03 grssnbchr

I managed to solve this issue by extracting the .AppImage file and running the application from the extracted files.

Started encountering the issue after trying to run TheAssassin/AppImageLauncher on my system which didn't work as I'm using Linux version that it does not support, or at least has problems with (using Linux Mint 21.3 Cinnamon).

How to fix:

  1. Download AppImage for Cursor.
  2. Run:
    ./cursor.AppImage --appimage-extract
    cd squashfs-root
    ./AppRun
    

Now Python displays the correct sys.executable after application launch.

Used Cursor 0.46.9 and zsh as shell, do not have terminal.integrated.defaultProfile.linux set in Cursor config.

https://github.com/user-attachments/assets/b7cc84ca-3dc1-4867-a705-4700a1607157

eioo avatar Mar 06 '25 05:03 eioo

@eioo This works, thanks! If you want to run the extracted AppRun from the launcher, do the following:

sudo cp -r /squashfs-root /opt/Cursor
sudo cp /opt/Cursor/cursor.desktop /usr/share/applications

then edit /usr/share/applications/cursor.deskop and overwrite it with the following

[Desktop Entry]
Name=Cursor
Comment=The AI Code Editor.
GenericName=Text Editor
Exec=/opt/Cursor/AppRun %F
Icon=/opt/Cursor/co.anysphere.cursor.png
Type=Application
StartupNotify=false
StartupWMClass=Cursor
Categories=TextEditor;Development;IDE;
MimeType=application/x-cursor-workspace;
Actions=new-empty-window;
Keywords=cursor;

X-AppImage-Version=0.46.9-3395357a4ee2975d5d03595e7607ee84e3db0f2c.deb.glibc2.25

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=/opt/Cursor/AppRun --new-window %F
Icon=/opt/Cursor/co.anysphere.cursor.png

grssnbchr avatar Mar 06 '25 06:03 grssnbchr

I managed to solve this issue by extracting the .AppImage file and running the application from the extracted files.

Started encountering the issue after trying to run TheAssassin/AppImageLauncher on my system which didn't work as I'm using Linux version that it does not support, or at least has problems with (using Linux Mint 21.3 Cinnamon).

How to fix:

  1. Download AppImage for Cursor.
  2. Run: ./cursor.AppImage --appimage-extract cd squashfs-root ./AppRun

Now Python displays the correct sys.executable after application launch.

Used Cursor 0.46.9 and zsh as shell, do not have terminal.integrated.defaultProfile.linux set in Cursor config.

2025-03-06_07-13-20.mp4

@eioo This works, thanks! If you want to run the extracted AppRun from the launcher, do the following:

sudo cp -r /squashfs-root /opt/Cursor
sudo cp /opt/Cursor/cursor.desktop /usr/share/applications

then edit /usr/share/applications/cursor.deskop and overwrite it with the following

[Desktop Entry]
Name=Cursor
Comment=The AI Code Editor.
GenericName=Text Editor
Exec=/opt/Cursor/AppRun %F
Icon=/opt/Cursor/co.anysphere.cursor.png
Type=Application
StartupNotify=false
StartupWMClass=Cursor
Categories=TextEditor;Development;IDE;
MimeType=application/x-cursor-workspace;
Actions=new-empty-window;
Keywords=cursor;

X-AppImage-Version=0.46.9-3395357a4ee2975d5d03595e7607ee84e3db0f2c.deb.glibc2.25

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=/opt/Cursor/AppRun --new-window %F
Icon=/opt/Cursor/co.anysphere.cursor.png

Works like a charm! Thanks!

RyoJerryYu avatar Mar 28 '25 03:03 RyoJerryYu

I've just updated to Cursor 0.49 and this is still happening. It seems that ZSH is not supported.

ljfp avatar Apr 17 '25 17:04 ljfp

On fedora, using zsh, same sort of issue.

I found there were some junk configs getting injected by cursor at ls -la ~/.local/lib/python*/site-packages/ | grep -i <my weird search term> -- after clearing that out it worked as expected.

I use uv primarily and have a fixed folder to manage virtual environments, so it was a bit easier to diagnose. But somewhere in sys path this is getting injected by cursor. Yuck.

tom-flamelit avatar Apr 25 '25 16:04 tom-flamelit

Problem is still there...

on3dd avatar Jun 21 '25 10:06 on3dd

From my experience, I'd say it's already resolved for a month or two.

p4l1ly avatar Nov 24 '25 14:11 p4l1ly