My virtual environment is buggy when i create a terminal inside cursor. e.g. the dependencies are not recognized. Pleas
On the image on the left is my cursor ide with the terminal. Even though I am in the virtual environment named ‘golf’, I can’t see my opencv installed. On the right, I have opened regular terminal and I can see opencv in my virtual env.
this issue typically occurs when Cursor’s terminal isn’t properly loading the virtual environment’s path. to troubleshoot:
- run these commands in both Cursor’s terminal and a regular terminal:
which python
echo $VIRTUAL_ENV
echo $PATH
- compare the outputs to verify if Cursor is using the correct python interpreter and environment paths.
The first two commands which python
and echo $VIRTUAL_ENV
have the same output in cursor vs regular terminal. The output of echo $PATH
is different; cursor’s terminal has additional directory: /home/user/.cursor/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/zsh
.
The only solution that has worked for me is if I deactivate the environment (for each cursor terminal) and then reactivate again by sourcing the activate
file in the virtual environment. Also, executing deactivate
in cursor prints a warning message
grep: /home/user/.cursor/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/zsh/envVars.txt: No such file or directory
grep: /home/user/.cursor/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/zsh/envVars.txt: No such file or directory
grep: /home/user/.cursor/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/zsh/envVars.txt: No such file or directory
Also, once I manually activate, the additional directory in $PATH no longer exists