Cursor does not seem to understand the active conda environment from where it was started
Running on Ubuntu 24.04, cursor 0.40.3 In a terminal I activated the Python project's conda environment, then started cursor with "cursor ." When editing one of the source files, all the non-standard package imports are marked as missing. Apparently, cursor does not understand the environment that is active when it gets started (as does vscode, for example). There is also no easily discoverable way to tell cursor from within the editor which conda environment to use (as there is for example in PyCharm).
The newest update broke this for me as well. Now I have to manually activate it after each new terminal session.
I am running.0.40.3 on Linux appimage as well
Hi, I encountered the exact same problem but was able to find a workaround: First open the Command Palette by pressing Ctrl+Shift+P, proceed to search for Python: Select Interpreter. FInally you want to point cursor to the Python binary of your custom Conda environment (mine is located at ~/anaconda3/envs/{my_env}/bin/python).
I'm having the same issue as the OP well. Running cursor-appimage 0.40.3-1 from AUR on Manjaro linux.
Environment selection and non-standard modules load up perfectly fine in VS Code, but not in cursor.
Same here: Version: 0.40.4 VSCode Version: 1.91.1 Commit: 63dae81aea2c3fc079420fe72578a8eef26ba870 Date: 2024-09-05T02:52:05.660Z Electron: 29.4.0 ElectronBuildId: undefined Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.6.0
Found a workaround, but I still can't figure out why this occurs. Wrote a short blog post on it https://www.andrewlis.blog/posts/2024-09-22-cursing-cursor/2024-09-22-cursing-cursor
Same issue with conda/mamba. This is quite insane, the cursor terminal doesn't behave like a normal terminal. I don't even understand how this is technically possible, pls try to fix it soon! Makes cursor almost unusable for python
Quick update:
I've installed Cursor on a few Windows machines now, and this issue doesn't seem to happen. Seems specific to Linux.
I've updated to Cursor 0.42 on my Linux machine and this issue persists, even though 0.42 is based on a newer build of VS Code (1.93.1), which suggests this is not a VS Code bug, but something specific to the way Cursor integrates with terminals on Linux.
And for clarity, this issue is not specific to conda - it happens with venv as described in #2202.
It's too bad because this is the only thing holding me back from buying multiple licenses (personal + multiple licenses for work), and I'd imagine this may be true of many others.
is anyone working on fixing this important bug? it seems to be a showstopper for many who work with conda/venv
I can confirm that Cursor 0.42.5 still shows this bug on MacOS whereas VS Code does not show it at all - you can activate and deactivate any conda environment without any extra config.
The MacOS default setting in defaultSettings.json is:
"terminal.integrated.profiles.osx": {
"bash": {
"path": "bash",
"args": [
"-l"
],
"icon": "terminal-bash"
},
Shouldn't this source ~\.bash_profile like in VS Code?
What in Cursor overrides this setting so the conda initialization is not read?
can anyone work on fixing this? it turns down practically all people working with conda environments from using cursor...
I am very low-skill in this domain, but this code below worked for me for last couple months. I have to run it in new terminal every time ofc. But then I can run conda activate. However I was unable to figure out permanent fix today, threw all GPT models at it and many hours before it occurred to me to do old-school search and found this thread....omg :). Google not dead yet.
This is problem only on my windows machine. Macbbook is ok.
source /c/ProgramData/anaconda3/etc/profile.d/conda.sh
same issue here, is there anyone can help to fix it?
Same issue (OSX), is there a fix?
the issue is still in the latest version, any plan to fix it?
the issue is still in the latest version, any plan to fix it?
This whole repo hasn't had an update in 3 months, much less paying attention to any of these issues. I'm definitely looking for an alternative.
This whole repo hasn't had an update in 3 months, much less paying attention to any of these issues. I'm definitely looking for an alternative.
I also have given up that Cursor will fix this. Strange because they just need to use the standard VS Code terminal without alteration.
As for alternative, the best bet is Windsurf. The UI almost looks like Cursor as both are based on Visual Studio Code. Here's my subjective review of both their main advantages.
Cursor:
- You can use the free version with API keys for Sonnet or ChatGPT
- Faster code completions
- tab-to-complete: after one code change, it suggests corresponding code changes for which you just tab. IMHO the most competitive feature when it works
Windsurf:
- works with conda environments
- free model (Cascade Base) is very fast and often enough
- paid version cheaper than Cursor ($15 vs. $20 per month, and $10 vs $20 for additional 500 requests to premium models)
- The internal prompt for premium models is slightly better for refactorings (this is subtle, subjective and only sometimes)
Conclusion: Both Cursor and Windsurf are almost identical in terms of features and UI. They used to say that Windsurf is better for beginners but I don't think that's the case any more. It comes down to personal preferences of the above.
Same issue. Been dealing with this for months now -- though I am using uv venv rather than conda.
Same here. I upgraded the cursor version and facing this issue..I am using Ubuntu
Wow this is still not fixed after such a long time (this issue was create on Sep 1st 2024) ? I think it was a good decision not to bother with cursor anymore since then.
I think the issue happens when you have multiple cursor windows open, opening a new window does not reflect the environment of where the new window is opened but only the original window.
I seem to be able to fix it by the Ctrl+P fix, though it definitely works different than regular VS Code, and if you don't do the Ctrl+P fix then you cannot control the set environment, which is crazy.
Found a workaround, but I still can't figure out why this occurs. Wrote a short blog post on it https://www.andrewlis.blog/posts/2024-09-22-cursing-cursor/2024-09-22-cursing-cursor
Saidly not working for me.
OS Name: Ubuntu 24.04.2 LTS Started as AppImage: cursor-0.45.14-build-250219jnihavxsz-x86_64.AppImage
Behavior is exactly as described here: https://github.com/getcursor/cursor/issues/2202
My workaround is to tell the agent to use uv instead of using python.
Just add a cursor rule in your workspace folder add a file .cursor/rules/use-uv-for-python.mdc with:
# Your rule content
- Never ever install any python package globally!
- use uv to install packages in the project
- activate the venv with `source .venv/bin/activate`
- instead of the `python` use `uv run` to run a python script
Same issue here
I followed this link exactly and now able to run anaconda in cursor. I am using Ubuntu 20.04 LTS. https://gist.github.com/evgenyneu/5c5c37ca68886bf1bea38026f60603b6
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.12/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/conda/cli/main.py", line 109, in main_sourced
print(activator.execute(), end="")
^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 206, in execute
return getattr(self, self.command)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 171, in activate
builder_result = self.build_activate(self.env_name_or_prefix)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 349, in build_activate
return self._build_activate_stack(env_name_or_prefix, False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 439, in _build_activate_stack
deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 771, in _get_deactivate_scripts
for entry in os.scandir(join(prefix, "etc", "conda", "deactivate.d"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
`$ /opt/miniconda3/bin/conda shell.posix activate base`
environment variables:
AUTOJUMP_ERROR_PATH=/Users/mk/Library/autojump/errors.log
CIO_TEST=<not set>
CONDA_EXE=/opt/miniconda3/bin/conda
CONDA_PREFIX_2=/opt/miniconda3/envs/py311
CONDA_PREFIX_3=/opt/miniconda3
CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
CONDA_ROOT=/opt/miniconda3
CONDA_SHLVL=4
CURL_CA_BUNDLE=<not set>
INFOPATH=/opt/homebrew/share/info:
LD_PRELOAD=<not set>
PATH=<MYPATH>
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : None
shell level : 4
user config file : /Users/mk/.condarc
populated config files :
conda version : 24.3.0
conda-build version : not installed
python version : 3.12.2.final.0
solver : libmamba (default)
virtual packages : __archspec=1=m1
__conda=24.3.0=0
__osx=15.3.1=0
__unix=0=0
base environment : /opt/miniconda3 (writable)
conda av data dir : /opt/miniconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-arm64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /opt/miniconda3/pkgs
/Users/mk/.conda/pkgs
envs directories : /opt/miniconda3/envs
/Users/mk/.conda/envs
platform : osx-arm64
user-agent : conda/24.3.0 requests/2.31.0 CPython/3.12.2 Darwin/24.3.0 OSX/15.3.1 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8
UID:GID : 501:20
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.
Example: conda --no-plugins install <package>
Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.
Example: CONDA_NO_PLUGINS=true conda install <package>
Timeout reached. No report sent.
I'm not sure if this is related to the same issue - but this is what I get when I try to activate a conda env in Cursor terminal.
Ok, took a bit of debugging, but I've figured it out. Issue is not related to Cursor, but to the way conda registers itself in ~/.bash_profile (for OSX or ~/.bashrc for Linux). Diagnosing the issue: Open new terminal (the normal one you use) and run:
conda activate py311_jupyterlab (your env)
echo $PATH
which pip
For pip it should tell something like: /Users/alekseyv/miniconda3/envs/py311_jupyterlab/bin/pip (note that path has your env).
Now open new terminal and run:
bash -l
conda activate py311_jupyterlab (your env)
echo $PATH
which pip
If it shows something that doesn't have your env path, that's the problem. Cursor starts embedded terminal in a same manner. If you have other modifications in ~/.bash_profile (it was Homebrew) in my case they interfere with each other. The problem lies in the order and redundancy of PATH modifications, particularly with Homebrew and Conda. Running bash -l starts a new login shell within your existing terminal session. A login shell always re-executes ~/.bash_profile, regardless of the parent shell’s state, and that messes up the PATH variable and therefore all python setup. The solution is to run conda intialization to run first and to make sure that it listed in path first.
Here is an example of my fixed ~/.bash_profile that works properly with Cursor:
# >>> conda initialize >>>
__conda_setup="$('/Users/alekseyv/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
# note this part:
if [ -n "$CONDA_PREFIX" ]; then
export PATH="$CONDA_PREFIX/bin:$PATH"
fi
else
if [ -f "/Users/alekseyv/miniconda3/etc/profile.d/conda.sh" ]; then
echo "conda.sh"
. "/Users/alekseyv/miniconda3/etc/profile.d/conda.sh"
else
echo "conda update path"
export PATH="/Users/alekseyv/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH="/Users/alekseyv/homebrew/opt/ruby/bin:$PATH"
echo "sourcing ~/.bash_profile"
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<< Traceback (most recent call last): File "/opt/miniconda3/lib/python3.12/site-packages/conda/exception_handler.py", line 17, in __call__ return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.12/site-packages/conda/cli/main.py", line 109, in main_sourced print(activator.execute(), end="") ^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 206, in execute return getattr(self, self.command)() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 171, in activate builder_result = self.build_activate(self.env_name_or_prefix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 349, in build_activate return self._build_activate_stack(env_name_or_prefix, False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 439, in _build_activate_stack deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.12/site-packages/conda/activate.py", line 771, in _get_deactivate_scripts for entry in os.scandir(join(prefix, "etc", "conda", "deactivate.d")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen posixpath>", line 76, in join TypeError: expected str, bytes or os.PathLike object, not NoneType `$ /opt/miniconda3/bin/conda shell.posix activate base` environment variables: AUTOJUMP_ERROR_PATH=/Users/mk/Library/autojump/errors.log CIO_TEST=<not set> CONDA_EXE=/opt/miniconda3/bin/conda CONDA_PREFIX_2=/opt/miniconda3/envs/py311 CONDA_PREFIX_3=/opt/miniconda3 CONDA_PYTHON_EXE=/opt/miniconda3/bin/python CONDA_ROOT=/opt/miniconda3 CONDA_SHLVL=4 CURL_CA_BUNDLE=<not set> INFOPATH=/opt/homebrew/share/info: LD_PRELOAD=<not set> PATH=<MYPATH> REQUESTS_CA_BUNDLE=<not set> SSL_CERT_FILE=<not set> active environment : None shell level : 4 user config file : /Users/mk/.condarc populated config files : conda version : 24.3.0 conda-build version : not installed python version : 3.12.2.final.0 solver : libmamba (default) virtual packages : __archspec=1=m1 __conda=24.3.0=0 __osx=15.3.1=0 __unix=0=0 base environment : /opt/miniconda3 (writable) conda av data dir : /opt/miniconda3/etc/conda conda av metadata url : None channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/osx-arm64 https://repo.anaconda.com/pkgs/r/noarch package cache : /opt/miniconda3/pkgs /Users/mk/.conda/pkgs envs directories : /opt/miniconda3/envs /Users/mk/.conda/envs platform : osx-arm64 user-agent : conda/24.3.0 requests/2.31.0 CPython/3.12.2 Darwin/24.3.0 OSX/15.3.1 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8 UID:GID : 501:20 netrc file : None offline mode : False An unexpected error has occurred. Conda has prepared the above report. If you suspect this error is being caused by a malfunctioning plugin, consider using the --no-plugins option to turn off plugins. Example: conda --no-plugins install <package> Alternatively, you can set the CONDA_NO_PLUGINS environment variable on the command line to run the command without plugins enabled. Example: CONDA_NO_PLUGINS=true conda install <package> Timeout reached. No report sent.I'm not sure if this is related to the same issue - but this is what I get when I try to activate a
condaenv in Cursor terminal.
unclick shell integration works for me.
The only thing which worked for me was the suggestion by @vlasenkoalexey 👍
Same issue. It behaviors different like vscode, even in UV environment. I just want to have a less step for environment choosing. There are no body in Cursor team use python to develop?
Cursor have been recognized the Python enviroment, but it got this error. The code snippet still run smoothly.